the struts dispatcher cannot be found_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > the struts dispatcher cannot be found

the struts dispatcher cannot be found

 2012/4/25 17:12:29  ZhanzhongChu  程序员俱乐部  我要评论(0)
  • 摘要:在struts2.0中直接访问jsp路径,有时候会出现这样的错误:Error500--InternalServerErrorTheStrutsdispatchercannotbefound.ThisisusuallycausedbyusingStrutstagswithouttheassociatedfilter.Strutstagsareonlyusablewhentherequesthaspassedthroughitsservletfilter
  • 标签:can not struts
struts2.0中直接访问jsp路径,有时候会出现这样的错误: Error 500--Internal Server Error The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location] at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60) at org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:52) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49) at jsp_servlet._report.__customerinfo._jspService(__customerinfo.java:133) at weblogic.servlet.jsp.JspBase.service(JspBase.java:34) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3242) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2010) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1916) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181) 错误提示里已经说得很明白:这通常是由于不经由Filter访问包含struts标签的jsp页面导致的。那么,只要通过配置,使得对jsp页面的访问请求由Filter过滤转发即可。 方法1:在strut.xml中配置一个通用Action,通过这个Action转发到jsp页面。这个时候,原先访问jsp的请求路径就要换成相应的Action路径了。写法如下。 <action name="*"><result>/{1}.jsp</result></action> 方法2:在web.xml中配置Filter的url-parttern。写法如下。其中struts2-dispatcher 是已定义的Filter。 <filter-mapping><filter-name>struts2-dispatcher </filter-name><url-pattern>*.action </url-pattern></filter-mapping><filter-mapping><filter-name>struts2-dispatcher </filter-name><url-pattern>*.jsp </url-pattern></filter-mapping> 方法3:在web.xml中配置扩展名。写法如下。配置完成后,就可以这样访问了:http://localhost:8080/yk_cpp/public/index.html 在web.xml中加 <init-param><param-name>struts.action.extension</param-name><param-value>html</param-value></init-param> 在struts.xml中加 <constant name="struts.action.extension" value="html"></constant> 方法4:修改struts.properties文件。去struts2的包里看一下default.properties,里面默认的action是struts.action.extension=action,,(注意有两个逗号,意思是第二个配置是空)空是全部拦截。在这里修改要拦截的带扩展名的文件,比如struts.action.extension=action,jnlp,do 不过这些没有经过测试;因为我的本地服务器没有出500的错误,问题是出在正式服务器上的,所以没法调试。下次设法在本地重现一下问题,然后挨个试一试。
发表评论
用户名: 匿名