Struts.action.excludePattern does not work,

struts.action.excludePattern does not work for me in Struts 2, I had a servlet cal place in the action form, the form will be sent to hyperlink.

struts.xml:

<constant name="struts.action.excludePattern" value="/PunchoutOrder"/> 

web.xml

  <servlet> <description></description> <display-name>PunchoutOrder</display-name> <servlet-name>PunchoutOrder</servlet-name> <servlet-class>com.PunchoutOrder</servlet-class> </servlet> <servlet-mapping> <servlet-name>PunchoutOrder</servlet-name> <url-pattern>/PunchoutOrder</url-pattern> </servlet-mapping> 

JSP:

 <form id="form1" name = "form1" method="post" action="PunchoutOrder"> <input type="image" alt="Submit" src="images/submit.png" onclick="Submit(form1);return false;"/> 

Below is below Error:

 15:26:37,512 WARN [Dispatcher] Could not find action or result There is no Action mapped for namespace / and action name PunchoutOrder. - [unknown location] at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189) at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) 

Am I missing something ...........?

Thanks.....

+4
source share
3 answers

In web.xml add .extention to the servlet url template

 <servlet-mapping> <servlet-name>PunchoutOrder</servlet-name> <url-pattern>/PunchoutOrder.srl</url-pattern> </servlet-mapping> 
-1
source

I had the same problem and came across a few tips on how to fix it. However, the solution I found, at least in Struts 2.2.2, was that I used the wrong filter in my web.xml. After some digging through Google and SO posts, I found that the change:

 <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 

To:

 <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 

After changing the filter, my exception pattern constant in struts.xml immediately began to function as expected.

It is also described here: https://cwiki.apache.org/confluence/display/S2WIKI/Troubleshooting+guide+migrating+from+Struts+2.0.x+to+2.1.x#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x -FilterMapping% 2CdefaultActionextensions% 2CandServlets

Although the previous entry indicated that I was explicitly declaring the extension of the action, I found that after fixing the filter declaration, it was not necessary.

+9
source

It seems that your syntax is not entirely correct. I ran into the same problem and the regex fix worked for me. After adding a line

 <constant name="struts.action.excludePattern" value="/exclude/.*?"/> 

in my struts.xml, everything works as expected. A query in this path now returns with 404 errors instead of the struts error message "There is no action displayed for the namespace ..."

amuses

+2
source

Source: https://habr.com/ru/post/1344079/


All Articles