错误一: 如果你也遇到以下问题: java.lang.IllegalArgumentException: Path index.jsp does not start with a / character org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1062) org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274) org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455) org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) model.MyActionServlet.process(MyActionServlet.java:22) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) javax.servlet.http.HttpServlet.service(HttpServlet.java:710) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 那么,请注意了。你的struts-config.xml文件一定是出错了,就仔细看看<action-mappings /> 吧! 特别是<action>里面 path=/admin/news <input=/xxx.jsp > <forward name=success path=/tran.jsp /> 如<input=logon.jsp> ==>input=/logon.jsp> path=admin/news ==>path=/admin/news <forward name=success path=tran.jsp /> ==><forward name=success path=/tran.jsp /> 有时,不一定是配置文件出的错。看看你的Action中的execute()方法,特别是retrun mapping.findForward(XXXXXXXXXXX), 我今天就错在这里了,本来的意思是return mapping.findForward(editnews); 可我却写成return new ActionForward(newslist);其实这句也对(如放在删除或者添加后面的 跳转 ),只不过放在这里就不对了,因为我的editnews在配置文件里已经定义过别名了<forward name=editnews path=/admin/newsedit.jsp /> ============================ 初学struts有些问题要注意! 我在这里说一些比较细的地方,都是我遇到过的,其他方面网上书上都说得很详细了。 struts-config.xml文件,这是很重要的地方,成败的关键啊!! 一般的样式就是这样,红色部分要注意 <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts Configuration 1.1//EN http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd> <struts-config> <data-sources /> <form-beans > <form-bean name=userLoginForm type=com.yourcompany.struts.form.UserLoginForm /> </form-beans> <global-exceptions /> <global-forwards /> <action-mappings > <action ------虽然在Eclipse开发当中,顺序不是这样,但是出问题时可以考虑先改这里的顺序,我试过在这里改了以后问题解决了��� attribute=userLoginForm input=/userLogin.jsp name=userLoginForm path=/userLogin scope=request type=com.yourcompany.struts.action.UserLoginAction validate=false> -------“/”这个也要注意,我在网上找错的时候,发现有不少也有这个错误Path 文件名字 does not start with a / character 记得加“/”这个,很容易就忘记,我是连续忘记了两次
错误二错误二错误二错误二::::HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Exception in JSP: /register/registerForm.jsp:38 35: </form> 36: 37: <table><tr><td><font color=red>用el表达式读取所有request作用中的错误对象:</font></td><td>${requestScope[org.apache.struts.action.ERROR]} </td></tr> 38: <tr><td><font color=red>用html标签读取所有request作用中的错误对象:</font></td><td><html:errors/></td></tr> 39: </table> 40: <table> 41: <tr><td></td> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063) org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1001) org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:966) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:204) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:710) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779) org.apache.jsp.register.registerForm_jsp._jspService(registerForm_jsp.java:154) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063) org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1001) org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:966) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:204) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:710) 解决方法: 没有配置国际化资源包,在 <tr><td><font color=red>用html标签,调用国际化资源包读取所有request作用中的错误对象<br>这个调用 的资源包在strutsconfig.xml文件中配置:</font></td><td><html:errors/></td></tr> <!-- 引入国际化资源包,在jsp页面中可以这样调用<html:errors/>--> <message-resources parameter=cn.pjtan.register.resources.Application></message-resources>
该贴由koei转至本版2014-5-2 16:21:58