struts入门级问题,在线等!!!!

04-05-25 linmin

初学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)

linmin
2004-05-25 17:05
论坛自动把html标签翻译了,看的不是很清楚,

简单重写一下,配置信息为:

# Optional header and footer for <errors/> tag.

errors.header=Errors

error.customer.name=Name is empty

fairy
2004-05-25 17:14
P注

banq
2004-05-25 20:46
Cannot find message resources under key org.apache.struts.action.MESSAGE

没有发现相关message资源,估application.proper这样文件出错

linmin
2004-05-26 11:44
请看apusic的提示信息:

(似乎已经成功载入了,因为PropertyMessageResources的初始化已经成功,只是在处理过程中好象又找不到它了)

2003-05-27 10:42:26 信息 [apusic.service.Muxer] 侦听端口 6888

2003-05-27 10:42:27 信息 [apusic.service.Muxer] 侦听端口 6889

2003-05-27 10:42:27 信息 [apusic.service.Muxer] 成功启动

2003-05-27 10:42:27 信息 [apusic.service.ORB] 成功启动

2003-05-27 10:42:27 信息 [apusic.service.Naming] 成功启动

2003-05-27 10:42:27 信息 [apusic.service.Transaction] 成功启动

2003-05-27 10:42:28 信息 [apusic.service.Security] 成功启动

2003-05-27 10:42:28 信息 [apusic.JDBC.SampleDB] 成功启动

2003-05-27 10:42:28 信息 [apusic.service.JDBC] 成功启动

2003-05-27 10:42:28 信息 [apusic.service.JCA] 成功启动

2003-05-27 10:42:28 信息 [apusic.service.EJB] 成功启动

2003-05-27 10:42:28 信息 [apusic.service.ACPEndpoint] 成功启动

2003-05-27 10:42:28 信息 [apusic.service.MUXEndpoint] 成功启动

2003-05-27 10:42:28 信息 [apusic.service.Web] 成功启动

2003-05-27 10:42:28 信息 [apusic.service.HttpSession] 成功启动

2003-05-27 10:42:28 信息 [apusic.service.JMSMessageStoreProvider] 成功启动

2003-05-27 10:42:29 信息 [apusic.JMS.JMSQueue.testQueue] 成功启动

2003-05-27 10:42:29 信息 [apusic.JMS.JMSQueue.system.undeliverable] 成功启动

2003-05-27 10:42:29 信息 [apusic.JMS.JMSTopic.testTopic] 成功启动

2003-05-27 10:42:29 信息 [apusic.JMS.ConnectionFactory.SecureQueueConnectionFactory] 成功启动

2003-05-27 10:42:29 信息 [apusic.JMS.ConnectionFactory.QueueConnectionFactory] 成功启动

2003-05-27 10:42:29 信息 [apusic.JMS.ConnectionFactory.SecureTopicConnectionFactory] 成功启动

2003-05-27 10:42:29 信息 [apusic.JMS.ConnectionFactory.TopicConnectionFactory] 成功启动

2003-05-27 10:42:29 信息 [apusic.service.JMS] 成功启动

2003-05-27 10:42:30 信息 [apusic.webapp.admin./admin] jsp: init

2003-05-27 10:42:30 信息 [apusic.webapp.admin./admin] action: init

2003-05-27 10:42:30 信息 [apusic.application.admin] 成功启动

2003-05-27 10:42:32 信息 [apusic.ejb.mejb.jar.MEJB] EJB home 'ejb/mgmt/MEJB' 已注册。

2003-05-27 10:42:32 信息 [apusic.application.mejb.jar] 成功启动

2003-05-27 10:42:34 信息 [apusic.webapp.struts.war./struts] action: init

2003-05-27 10:42:34 信息 [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true

2003-05-27 10:42:34 信息 [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.action.ActionResources', returnNull=true

2003-05-27 10:42:35 信息 [apusic.application.struts.war] 成功启动

2003-05-27 10:42:35 信息 [apusic.service.J2EEDeployer] 成功启动

2003-05-27 10:42:36 信息 [apusic.service.RMIAdaptor] 成功启动

2003-05-27 10:42:36 信息 [apusic.service.WebServices] 成功启动

2003-05-27 10:42:36 信息 [apusic.server.Main] 服务器就绪。

2003-05-27 10:42:54 信息 [apusic.webapp.struts.war./struts] jsp: init

2003-05-27 10:42:54 信息 [apusic.webapp.struts.war./struts] /hello.jsp: init

2003-05-27 10:42:54 信息 [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true

2003-05-27 10:42:56 信息 [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true

2003-05-27 10:42:56 信息 [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true

2003-05-27 10:42:56 信息 [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true

2003-05-27 10:42:56 信息 [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true

2003-05-27 10:42:56 信息 [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true

2003-05-27 10:42:56 信息 [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true

2003-05-27 10:42:56 信息 [org.apache.struts.util.PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true

2003-05-27 10:42:56 信息 [apusic.webapp.struts.war./struts] file: init

2003-05-27 10:42:58 信息 [con.out] errors....

2003-05-27 10:42:58 错误 [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__0._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)

猜你喜欢