struts入門級問題,線上等!!!!

linmin發表於2004-05-25

初學struts,環境為jbx+apusic,問題非常簡單,請往下看,謝謝!
問題如下:

登陸頁面hello.jsp有一欄位為username,現透過一actionform對其進行包裝,並對username是否為空進行認證,如果該欄位為空,返回hello.jsp,並在該頁上顯示錯誤資訊。(我的感覺是漏做了一步配置)
actionform驗證碼為:
public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ((getUsername()==null)|| (getUsername().equals(""))) {
// if the name is empty --> errors
errors.add("username", new ActionError("error.customer.name"));
System.out.println("errors....");
}
return errors;
}
同時在ApplicationResources.properties裡設定具體錯誤顯示資訊:

# Optional header and footer for <errors/> tag.
errors.header=<hr><h3>Errors</h3><ul>
errors.footer=</ul><hr>
error.customer.name=<li>Name is empty

並在hello.jsp里加如<html:errors/>
但執行時總出現錯誤:

2003-05-26 16:50:37 錯誤 [apusic.webapp.struts.war./struts] 執行Servlet時發生錯誤。
javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
at org.apache.struts.util.RequestUtils.retrieveMessageResources(RequestUtils.java:1103)
at org.apache.struts.util.RequestUtils.present(RequestUtils.java:1408)
at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:196)
at _jspx._hello__jsp__1._jspService(hello.jsp:26)
at com.apusic.servlet.jsp.HttpJspPageImpl.service(Unknown Source:43)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.apusic.servlet.http.lllllIIllIIlIlIl._$1(Unknown Source:664)
at com.apusic.servlet.http.lllllIIllIIlIlIl._$1(Unknown Source:562)
at com.apusic.servlet.jsp.JspServlet.service(Unknown Source:247)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.apusic.servlet.http.lllllIIllIIlIlIl._$1(Unknown Source:664)
at com.apusic.servlet.http.IIIIIlIIIlIIIlIl.forward(Unknown Source:121)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.apusic.servlet.http.lllllIIllIIlIlIl._$1(Unknown Source:664)
at com.apusic.servlet.http.lllllIIllIIlIlIl._$1(Unknown Source:504)
at com.apusic.servlet.http.IIlIIIIlIIlIIllI._$1(Unknown Source:169)
at com.apusic.servlet.http.lllIIlIIIIIlIlII._$1(Unknown Source:283)
at com.apusic.servlet.http.llIlllllIllIIIll._$1(Unknown Source:25)
at com.apusic.servlet.http.lIllIIllllllIlll._$3(Unknown Source:238)
at com.apusic.servlet.http.lIllIIllllllIlll._$1(Unknown Source:142)
at com.apusic.servlet.http.lIllIIllllllIlll.run(Unknown Source:70)

相關文章