步骤 2 : 模仿和排错 步骤 3 : 界面效果 步骤 4 : login.jsp 步骤 5 : UserService 步骤 6 : UserServiceImpl 步骤 7 : loginPage.jsp 步骤 8 : ForeController.login()
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isELIgnored="false"%>
<%@include file="../include/fore/header.jsp"%>
<%@include file="../include/fore/loginPage.jsp"%>
<%@include file="../include/fore/footer.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%> <%@include file="../include/fore/header.jsp"%> <%@include file="../include/fore/loginPage.jsp"%> <%@include file="../include/fore/footer.jsp"%>
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service;
import java.util.List;
import com.how2java.tmall.pojo.User;
public interface UserService {
void add(User c);
void delete(int id);
void update(User c);
User get(int id);
List list();
boolean isExist(String name);
User get(String name, String password);
}
package com.how2java.tmall.service; import java.util.List; import com.how2java.tmall.pojo.User; public interface UserService { void add(User c); void delete(int id); void update(User c); User get(int id); List list(); boolean isExist(String name); User get(String name, String password); }
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.how2java.tmall.mapper.UserMapper;
import com.how2java.tmall.pojo.User;
import com.how2java.tmall.pojo.UserExample;
import com.how2java.tmall.service.UserService;
@Service
public class UserServiceImpl implements UserService {
@Autowired
UserMapper userMapper;
@Override
public void add(User u) {
userMapper.insert(u);
}
@Override
public void delete(int id) {
userMapper.deleteByPrimaryKey(id);
}
@Override
public void update(User u) {
userMapper.updateByPrimaryKeySelective(u);
}
@Override
public User get(int id) {
return userMapper.selectByPrimaryKey(id);
}
public List<User> list(){
UserExample example =new UserExample();
example.setOrderByClause("id desc");
return userMapper.selectByExample(example);
}
@Override
public boolean isExist(String name) {
UserExample example =new UserExample();
example.createCriteria().andNameEqualTo(name);
List<User> result= userMapper.selectByExample(example);
if(!result.isEmpty())
return true;
return false;
}
@Override
public User get(String name, String password) {
UserExample example =new UserExample();
example.createCriteria().andNameEqualTo(name).andPasswordEqualTo(password);
List<User> result= userMapper.selectByExample(example);
if(result.isEmpty())
return null;
return result.get(0);
}
}
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isELIgnored="false"%>
<script>
$(function(){
<c:if test="${!empty msg}">
$("span.errorMessage").html("${msg}");
$("div.loginErrorMessageDiv").show();
</c:if>
$("form.loginForm").submit(function(){
if(0==$("#name").val().length||0==$("#password").val().length){
$("span.errorMessage").html("请输入账号密码");
$("div.loginErrorMessageDiv").show();
return false;
}
return true;
});
$("form.loginForm input").keyup(function(){
$("div.loginErrorMessageDiv").hide();
});
var left = window.innerWidth/2+162;
$("div.loginSmallDiv").css("left",left);
})
</script>
<div id="loginDiv" style="position: relative">
<div class="simpleLogo">
<a href="${contextPath}"><img src="img/site/simpleLogo.png"></a>
</div>
<img id="loginBackgroundImg" class="loginBackgroundImg" src="img/site/loginBackground.png">
<form class="loginForm" action="forelogin" method="post">
<div id="loginSmallDiv" class="loginSmallDiv">
<div class="loginErrorMessageDiv">
<div class="alert alert-danger" >
<button type="button" class="close" data-dismiss="alert" aria-label="Close"></button>
<span class="errorMessage"></span>
</div>
</div>
<div class="login_acount_text">账户登录</div>
<div class="loginInput " >
<span class="loginInputIcon ">
<span class=" glyphicon glyphicon-user"></span>
</span>
<input id="name" name="name" placeholder="手机/会员名/邮箱" type="text">
</div>
<div class="loginInput " >
<span class="loginInputIcon ">
<span class=" glyphicon glyphicon-lock"></span>
</span>
<input id="password" name="password" type="password" placeholder="密码" type="text">
</div>
<span class="text-danger">不要输入真实的天猫账号密码</span><br><br>
<div>
<a class="notImplementLink" href="#nowhere">忘记登录密码</a>
<a href="registerPage" class="pull-right">免费注册</a>
</div>
<div style="margin-top:20px">
<button class="btn btn-block redButton" type="submit">登录</button>
</div>
</div>
</form>
</div>
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
@RequestMapping("forelogin")
public String login(@RequestParam("name") String name, @RequestParam("password") String password, Model model, HttpSession session) {
name = HtmlUtils.htmlEscape(name);
User user = userService.get(name,password);
if(null==user){
model.addAttribute("msg", "账号密码错误");
return "fore/login";
}
session.setAttribute("user", user);
return "redirect:forehome";
}
}
package com.how2java.tmall.controller;
import com.how2java.tmall.pojo.Category;
import com.how2java.tmall.pojo.User;
import com.how2java.tmall.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.util.HtmlUtils;
import javax.servlet.http.HttpSession;
import java.util.List;
@Controller
@RequestMapping("")
public class ForeController {
@Autowired
CategoryService categoryService;
@Autowired
ProductService productService;
@Autowired
UserService userService;
@Autowired
ProductImageService productImageService;
@Autowired
PropertyValueService propertyValueService;
@Autowired
OrderService orderService;
@Autowired
OrderItemService orderItemService;
@RequestMapping("forehome")
public String home(Model model) {
List<Category> cs= categoryService.list();
productService.fill(cs);
productService.fillByRow(cs);
model.addAttribute("cs", cs);
return "fore/home";
}
@RequestMapping("foreregister")
public String register(Model model,User user) {
String name = user.getName();
name = HtmlUtils.htmlEscape(name);
user.setName(name);
boolean exist = userService.isExist(name);
if(exist){
String m ="用户名已经被使用,不能使用";
model.addAttribute("msg", m);
return "fore/register";
}
userService.add(user);
return "redirect:registerSuccessPage";
}
@RequestMapping("forelogin")
public String login(@RequestParam("name") String name, @RequestParam("password") String password, Model model, HttpSession session) {
name = HtmlUtils.htmlEscape(name);
User user = userService.get(name,password);
if(null==user){
model.addAttribute("msg", "账号密码错误");
return "fore/login";
}
session.setAttribute("user", user);
return "redirect:forehome";
}
}
HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。
问答区域
2020-11-20
为什么不打注释?
2020-07-23
请教一下关于@RequestParam的问题
回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
2020-06-21
登陆问题
2020-05-15
关于单点登录的疑问
2020-03-16
站长,这里输入框有点不对称,用的谷歌,如图
提问太多,页面渲染太慢,为了加快渲染速度,本页最多只显示几条提问。还有 27 条以前的提问,请 点击查看
提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
|