Struts 2.0 Error: The Struts dispatcher cannot be found (Error 500 Internal Server Error)

When you directly access the JSP path in struts 2.0, sometimes there will be such an error:

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)
The error message is clear: this is usually caused by not accessing the jsp page containing struts tags through Filter. So, just configure it so that requests for jsp pages are filtered and forwarded by Filter.

Method 1: configure a general action in struts.xml and forward it to JSP page through this action. At this time, the original request path to access JSP will be changed to the corresponding action path. It’s written as follows

<action name="*">
<result>/{1}.jsp</result>
</action>

Method 2: configure the URL part of filter in web.xml. It’s written as follows. Where Struts2 dispatcher is the defined 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>

Method 3: configure the extension in the web. XML. It’s written as follows. After the configuration is completed, you can access it as follows: http://localhost:8080/yk_ cpp/public/index.html

Add
in web.xml

<init-param> 
<param-name>struts.action.extension</param-name> 
<param-value>html</param-value> 
</init-param>

Add
<in struts.xml; constant name=”struts.action.extension” value=”html” />

Method 4: modify the struts. Properties file. Go to the package of Struts2 and look at default. Properties. The default action is struts. Action. Extension = action. Modify the file with an extension to be intercepted, such as struts. Action. Extension = action, JNLP, do

I used the second method to solve this problem

Similar Posts: