zoukankan      html  css  js  c++  java
  • The Struts dispatcher cannot be found

    在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" />

    方法4:修改struts.properties文件。去struts2的包里看一下default.properties,里面默认的action是struts.action.extension=action,,(注意有两个逗号,意思是第二个配置是空)空是全部拦截。在这里修改要拦截的带扩展名的文件,比如struts.action.extension=action,jnlp,do

    我出现这个的问题 我使用了第二种方法解决了。

    转载出处:http://blog.sina.com.cn/s/blog_4745d1c101012wq4.html

  • 相关阅读:
    WPF Window对象的生命周期
    MVC 控制器中传递dynamic(对象) 给视图
    MVC 获取路由的 URL 参数值和默认值的集合。
    mvc路由配置.html结尾的伪静态
    javascript 模拟按键点击提交
    微信小程序调用接口返回数据或提交数据
    清理电脑文件夹中的Thumbs.db文件
    asp.net动态增加服务器端控件并提交表单
    c# asp.net 实现分页(pager)功能
    注册时发短信如何防止别人恶意调用短信接口
  • 原文地址:https://www.cnblogs.com/xiaopen/p/2517936.html
Copyright © 2011-2022 走看看