struts.action.excludePattern 不起作用,

发布于 2024-10-22 08:00:20 字数 1724 浏览 2 评论 0原文

struts.action.excludePattern 在 Struts 2 中对我不起作用,我将 servlet cal 放在表单操作中,表单将在超链接单击时提交。

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

低于错误:

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)

我错过了什么吗……?

谢谢.....

struts.action.excludePattern is not working for me in Struts 2, i had place servlet cal in form action, form will submit on hyperLink click.

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

Getting 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...........?

Thank you.....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

挖个坑埋了你 2024-10-29 08:00:20

我遇到了同样的问题,并遇到了一些如何解决它的提示。然而,我发现的解决方案(至少在 Struts 2.2.2 中)是我在 web.xml 中使用了错误的过滤器。经过一番挖掘 Google 和 SO 帖子后,我发现从: 更改

<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>

为:

<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>

更改过滤器后,struts.xml 中的排除模式常量立即开始按预期运行。

这也记录在此处: https://cwiki.apache.org/confluence/display/S2WIKI/Troubleshooting+guide+migration+from+Struts+2.0.x+to +2.1.x#TroubleshootingguidemigrationfromStruts2.0.xto2.1.x-FilterMapping%2CdefaultActionextensions%2CandServlets

虽然前面的条目说要显式声明操作扩展,但我发现在修复过滤器声明后没有必要。

I was having the same problem and ran into several hints at how to fix it. However the solution I found, at least in Struts 2.2.2 was that I was using the wrong filter in my web.xml. After some digging through Google and SO posts I found that changing from:

<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 exclusion pattern constant in the struts.xml immediately started functioning as expected.

This is also documented 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 says to explicitly declare the action extensions, I found it was unnecessary after fixing my filter declaration.

逐鹿 2024-10-29 08:00:20

看来你的语法不完全正确。我遇到了同样的问题,纠正正则表达式对我有用。将行添加

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

到我的 struts.xml 后,一切都按预期工作。此路径中的请求现在返回 404 错误,而不是 struts 错误消息“没有为命名空间映射的操作...”

欢呼

it seems as if your syntax isn't entirely correct. I fell upon the same issue and correcting the regular expression worked for me. After adding the line

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

to my struts.xml, everything works as expected. Request within this path are now returned with 404 errors instead of struts error message "There is no Action mapped for namespace ..."

cheers

呆橘 2024-10-29 08:00:20

在 web.xml 中,在 servlet url 模式中添加 .extention

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

In web.xml add .extention in servlet url pattern

<servlet-mapping>
    <servlet-name>PunchoutOrder</servlet-name>
    <url-pattern>/PunchoutOrder.srl</url-pattern>
  </servlet-mapping>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文