gpt4 book ai didi

servlets - struts.action.excludePattern 不起作用,

转载 作者:行者123 更新时间:2023-12-02 21:34:28 28 4
gpt4 key购买 nike

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 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+migrating+from+Struts+2.0.x+to+2.1.x#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-FilterMapping%2CdefaultActionextensions%2CandServlets

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

关于servlets - struts.action.excludePattern 不起作用,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5337647/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com