首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

<html:errors /> 标签不显示错误信息?

2014-01-26 
我用struts做的登陆,当验证失败时死活不显示错误提示也不报错,在jsp页面中添加的ActionErrors能显示?请教到

我用struts做的登陆,当验证失败时死活不显示错误提示
  也不报错,在jsp页面中添加的ActionErrors能显示?
  请教到底是什么地方错了?
 
 
  struts-config.xml 配置:
  <form-bean name="loginForm"
  type="com.xxx.user.web.LoginForm" />
  .....
  <action path="/login" type="com.xxx.mailuser.web.LoginAction" name="loginForm" scope="request" input="/user/login.jsp" validate="true">
  <forward name="success" path="/coremail/" />
  .....
  <message-resources parameter="ApplicationResources" />
  .....
 
  ApplicationResources.properties文件内容:
 
  test=111111
  property1error1=Property 1, Error 1
  topic.show.error=\u7528\u6237\u540d
  errors.login.userNameRequire=userName is require
  errors.login.passWordRequire=passWord is require
  errors.login.userNameNotExist=userName Not Exist
  errors.login.passWordFalse=passWord False
 
  LoginAction.java代码 :
  .....
  public class LoginAction extends Action
  {
  public LoginAction(){
  super();
  }
  public ActionForward execute (ActionMapping mapping,ActionForm actionForm,HttpServletRequest request,HttpServletResponse response){
  ActionErrors errors = new ActionErrors();
  ActionForward forward = mapping.getInputForward();
  LoginForm form = (LoginForm)actionForm;
  IUserManager userManager = UserManagerFactory.getInstance();
  UserInfo userInfo = new UserInfo();
  userInfo.setUserName(form.getUserName());
  userInfo.setPassWord(form.getPassWord());
  int result=userManager.login(userInfo);
  if(result==IUserManager.OK){
  request.getSession().setAttribute("userinfo",userInfo);
  forward = mapping.findForward("success");
  }else{
  if(result==IUserManager.USER_NOTEXIST)
  errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("errors.login.userNameNotExist"));
  if(result==IUserManager.PASSWORD_ERROR)
  errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("errors.login.passWordFalse"));
  }
  if (!errors.isEmpty()){
  saveErrors(request, errors);
  }
  return forward;
  }
  };
 
 
  login.jsp :
 
  <%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
  <%@ page import="org.apache.struts.action.*, org.apache.struts.Globals" %>
  <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
  <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
  <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
  <html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>登陆</title>
  </head>
 
  <body>
  <br>
  <%
 
  ActionErrors errors = new ActionErrors();         

热点排行