如何在没有 struts.xml 的基于注释的 struts2 项目中使用 servlet
How to use a servlet in annotations based struts2 project having no struts.xml
我是 Struts 的新手,我必须向遗留系统添加功能。
我必须创建一个需要从 JSP 页面访问的 servlet。我创建了一个并在 web.xml 文件中添加了 servlet-mapping,但它总是显示如下错误:
There is no Action mapped for namespace [/myServlet] and action name
[test] associated with context path [/MyProject]
我已经搜索了解决方案,但我得到的解决方案 here 是针对 sturts.xml 条目的,我没有使用 struts.xml,而是使用注释。
有人可以告诉我如何在基于注释的 Struts2 项目中使用 excludePattern
吗?
注意:我尝试在 web.xml 中添加排除模式,如下所示:
<init-param>
<param-name>struts.action.excludePattern</param-name>
<param-value>/FileUploadServlet</param-value>
</init-param>
但是还是不行。
嗯,我已经通过将 struts.xml 添加到我的项目并只添加常量来解决问题,如下所示:
<constant name="struts.action.excludePattern" value="/MyServlet"/>
我首先想知道我将不得不手动提供所有映射而不是注释,但它没有这样做就起作用了。
我是 Struts 的新手,我必须向遗留系统添加功能。
我必须创建一个需要从 JSP 页面访问的 servlet。我创建了一个并在 web.xml 文件中添加了 servlet-mapping,但它总是显示如下错误:
There is no Action mapped for namespace [/myServlet] and action name
[test] associated with context path [/MyProject]
我已经搜索了解决方案,但我得到的解决方案 here 是针对 sturts.xml 条目的,我没有使用 struts.xml,而是使用注释。
有人可以告诉我如何在基于注释的 Struts2 项目中使用 excludePattern
吗?
注意:我尝试在 web.xml 中添加排除模式,如下所示:
<init-param>
<param-name>struts.action.excludePattern</param-name>
<param-value>/FileUploadServlet</param-value>
</init-param>
但是还是不行。
嗯,我已经通过将 struts.xml 添加到我的项目并只添加常量来解决问题,如下所示:
<constant name="struts.action.excludePattern" value="/MyServlet"/>
我首先想知道我将不得不手动提供所有映射而不是注释,但它没有这样做就起作用了。