当前位置: 代码迷 >> Java Web开发 >> struts环境配置有关问题
  详细解决方案

struts环境配置有关问题

热度:274   发布时间:2016-04-17 12:28:02.0
struts环境配置问题
我在用STRUTS开发一个WEB程序时经常报如下错误:

我想应该是环境哪配错了,但从错误中又不知如何判断是哪的问题,请各位帮忙看一下吧,谢谢了!
exception 

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot create rewrite URL: java.net.MalformedURLException: Cannot retrieve ActionForward named login
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.page.index_jsp._jspService(index_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause 
javax.servlet.jsp.JspException: Cannot create rewrite URL: java.net.MalformedURLException: Cannot retrieve ActionForward named login
org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:467)
org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:341)
org.apache.jsp.page.top_jsp._jspx_meth_html_link_0(top_jsp.java:116)
org.apache.jsp.page.top_jsp._jspService(top_jsp.java:80)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(ImportSupport.java:296)
org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(ImportSupport.java:161)
org.apache.jsp.page.index_jsp._jspx_meth_c_import_0(index_jsp.java:169)
org.apache.jsp.page.index_jsp._jspx_meth_html_html_0(index_jsp.java:125)
org.apache.jsp.page.index_jsp._jspService(index_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



------解决方案--------------------
<html:link forward="login"> 
forward属性:
应该为一个global的ActionForward。
参考Struts Taglib Ref:
Logical name of a global ActionForward that contains the actual content-relative URI of the destination of this transfer.
------解决方案--------------------
看看你有没有这样的配置:

<global-forwards>
<forward name="login" path="/login.jsp"/>
</global-forwards>



<html:link forward="login">
Link
</html:link>
forward属性只能引用Struts配置文件中<global-forwards>内的<forward>子元素,如果引用<action>内的将抛出下面异常:Cannot create rewrite URL:Java.net.MalformedURLException:Cannot retrieve ActionForward
  相关解决方案