how2j.cn

下载区
文件名 文件大小
请先登录 18m
增值内容 18m
18m
步骤 1 : 先运行,看到效果,再学习   
步骤 2 : 模仿和排错   
步骤 3 : 界面效果   
步骤 4 : login.jsp   
步骤 5 : loginPage.jsp   
步骤 6 : UserService   
步骤 7 : UserServiceImpl   
步骤 8 : ForeAction.login()   

步骤 1 :

先运行,看到效果,再学习

edit
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
界面效果
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%> <%@include file="include/header.jsp"%> <%@include file="include/loginPage.jsp"%> <%@include file="include/footer.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>

<%@include file="include/header.jsp"%>
<%@include file="include/loginPage.jsp"%>
<%@include file="include/footer.jsp"%>
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<%@ 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="user.name" placeholder="手机/会员名/邮箱" type="text"> </div> <div class="loginInput " > <span class="loginInputIcon "> <span class=" glyphicon glyphicon-lock"></span> </span> <input id="password" name="user.password" type="password" placeholder="密码" type="text"> </div> <span class="text-danger">不要输入真实的天猫账号密码</span><br><br> <div> <a class="notImplementLink" href="#nowhere">忘记登录密码</a> <a href="register.jsp" class="pull-right">免费注册</a> </div> <div style="margin-top:20px"> <button class="btn btn-block redButton" type="submit">登录</button> </div> </div> </form> </div>
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service; import com.how2java.tmall.pojo.User; public interface UserService extends BaseService{ boolean isExist(String name); User get(String name, String password); }
package com.how2java.tmall.service;

import com.how2java.tmall.pojo.User;

public interface UserService extends BaseService{

	boolean isExist(String name);
	
	User get(String name, String password);

}
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service.impl; import java.util.List; import org.springframework.stereotype.Service; import com.how2java.tmall.pojo.User; import com.how2java.tmall.service.UserService; @Service public class UserServiceImpl extends BaseServiceImpl implements UserService { @Override public boolean isExist(String name) { List l = list("name",name); if(!l.isEmpty()) return true; return false; } @Override public User get(String name, String password) { List<User> l = list("name",name, "password",password); if(l.isEmpty()) return null; return l.get(0); } }
步骤 8 :

ForeAction.login()

edit
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
@Action("forelogin") public String login() { user.setName(HtmlUtils.htmlEscape(user.getName())); User user_session = userService.get(user.getName(),user.getPassword()); if(null==user_session){ msg= "账号密码错误"; return "login.jsp"; } ActionContext.getContext().getSession().put("user", user_session); return "homePage"; }
package com.how2java.tmall.action; import org.apache.struts2.convention.annotation.Action; import org.springframework.web.util.HtmlUtils; import com.how2java.tmall.pojo.User; import com.opensymphony.xwork2.ActionContext; public class ForeAction extends Action4Result { @Action("forelogin") public String login() { user.setName(HtmlUtils.htmlEscape(user.getName())); User user_session = userService.get(user.getName(),user.getPassword()); if(null==user_session){ msg= "账号密码错误"; return "login.jsp"; } ActionContext.getContext().getSession().put("user", user_session); return "homePage"; } @Action("foreregister") public String register() { user.setName(HtmlUtils.htmlEscape(user.getName())); boolean exist = userService.isExist(user.getName()); if(exist){ msg = "用户名已经被使用,不能使用"; return "register.jsp"; } userService.save(user); return "registerSuccessPage"; } @Action("forehome") public String home() { categorys = categoryService.list(); productService.fill(categorys); productService.fillByRow(categorys); return "home.jsp"; } }


HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。


问答区域    
2019-04-24 登陆界面里的forelogin方法
wryyyyyyyyyyy




这个代码,应该是说如果登陆密码错误,会提示密码错误,但是如果我把这个msg删掉,或者把return里面的返回值删掉或者替换为其他页面的,程序还是会正常的按照原来一样运行,这是怎么回事儿
加载中

							

							


1 个答案

how2j
答案时间:2019-04-25
改了代码不起作用,重启试试?



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到





2019-03-21 跳转方式ActionContext.getContext().getSession().put("user", user_session);
小柒




为什么要使用这种跳转,而不是使用之前的跳转方式 @Result(name="homePage", type = "redirect", location="forehome?user.id=${user_session.id}"),类似这种的方式,我用这种方式获取不到,我已经把User类的属性id设置为public权限了还是不能获取,如图
加载中
@Action("forelogin")
public String login() {
    user.setName(HtmlUtils.htmlEscape(user.getName()));
    User user_session = userService.get(user.getName(),user.getPassword());
    if(null==user_session){
        msg= "账号密码错误";
        return "login.jsp";
    }
    ActionContext.getContext().getSession().put("user", user_session);
    return "homePage";     
}

							


1 个答案

how2j
答案时间:2019-03-21
登录信息要放在session里哦



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到





2018-07-24 BaseService是什么
2018-07-23 登录时密码怎么拿到的?
2018-06-07 一个额外的问题


提问太多,页面渲染太慢,为了加快渲染速度,本页最多只显示几条提问。还有 1 条以前的提问,请 点击查看

提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 已下架实践项目-天猫整站SSH-登录 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 578362961
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: https://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图