为了账号安全,请及时绑定邮箱和手机立即绑定

登录后页面跳转问题

登录后页面跳转问题

慕先生5417536 2017-06-03 10:48:26
HTTP Status 500 -type Exception reportmessagedescription The server encountered an internal error that prevented it from fulfilling this request.exceptionjava.lang.NullPointerException action.UsersAction.validate(UsersAction.java:56) com.opensymphony.xwork2.validator.ValidationInterceptor.doBeforeInvocation(ValidationInterceptor.java:251) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) org.apache.struts2.interceptor.DateTextFieldInterceptor.intercept(DateTextFieldInterceptor.java:125) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:140) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:575) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)note The full stack trace of the root cause is available in the Apache Tomcat/7.0.77 logs.登陆后输入已有的账号密码zhangsan,123456并点击确定后就报错500了
查看完整描述

3 回答

?
精慕门9254224

TA贡献167条经验 获得超46个赞

空指针异常

查看完整回答
1 反对 回复 2017-06-03
?
qq_nullpointere_6

TA贡献10条经验 获得超12个赞

原图片 贴图

查看完整回答
反对 回复 2017-06-05
?
慕先生5417536

TA贡献1条经验 获得超0个赞

错误结果://img1.sycdn.imooc.com//5932640a000114cc08810694.jpg

UsersAction配置文件如下:

//img1.sycdn.imooc.com//5932644d0001b2f106110335.jpg

//img1.sycdn.imooc.com//5932644d0001522104760333.jpg

//img1.sycdn.imooc.com//5932644e0001cf2905020347.jpg

//img1.sycdn.imooc.com//5932644e00010c1505340341.jpg


查看完整回答
反对 回复 2017-06-03
?
路人Bing

TA贡献6条经验 获得超1个赞

没有UserAction相关代码,只能推测:在你逻辑没问题的情况下看你的配置文件,struts2配置是否有问题,spring的配置文件中跟User相关的的bean是否已经添加

查看完整回答
反对 回复 2017-06-03
  • 慕先生5417536
    慕先生5417536
    UserAction相关代码: package action; import org.apache.struts2.interceptor.validation.SkipValidation; import service.UsersDAO; import service.impl.UsersDAOImpl; import com.opensymphony.xwork2.ModelDriven; import entity.Users; public class UsersAction extends SuperAction implements ModelDriven<Users>{ /** * */ private static final long serialVersionUID = 1L; private Users user = new Users(); //用户登录动作 public String login() { UsersDAO udao = new UsersDAOImpl(); if(udao.usersLogin(user)) { //在session中保存登陆成功的用户名 session.setAttribute("loginUserName", user.getUsername()); return "login_success"; } else { return "login_failure"; } }
  • 慕先生5417536
    慕先生5417536
    @SkipValidation //用户注销方法 public String logout() { if(session.getAttribute("loginUserName")!=null) { session.removeAttribute("loginUserName"); } return "logout_success"; } @Override public void validate() { // TODO Auto-generated method stub //用户名不能为空 if("".equals(user.getUsername().trim())) { this.addFieldError("usernameError","用户名不能为空!"); } if(user.getPassword().length()<6) { this.addFieldError("passwordError","密码长度不少于6位"); } } public Users getModel(){ //TODO Auto-generated method stub return null; } }
  • 慕先生5417536
    慕先生5417536
    为什么代码格式这么难看...
  • 3 回答
  • 0 关注
  • 1942 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信