在 struts 2 项目中使用 servlet [英] using servlets in a struts 2 project
问题描述
我正在使用 struts2 构建一个应用程序.web.xml 文件如下所示
I am building an application using struts2. The web.xml file looks like below
<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>
应用程序运行良好.现在我有一个 JSP 需要来自 servlet 的一些输入,所以我写了一个 servlet 并在 web.xml 中添加了 servlet-mapping,但是由于过滤器映射,服务器找不到 servlet.如何在struts 2中使用servlets,web.xml应该是什么样子的?
The application runs fine. Now I have a JSP which needs some input from servlet, So i wrote a servlet and added servlet-mapping in web.xml, but the server cannot find the servlet because of the filter-mapping. How to use servlets in struts 2 and what should web.xml look like?
来自:http://struts-2.464677.n5.nabble.com/using-servlets-in-a-struts-2-project-td465399.html
推荐答案
应该从 struts.xml 中的 Struts 过滤器中排除那个特定的 servlet
That particular servlet should be excluded from you Struts filter in struts.xml
这篇关于在 struts 2 项目中使用 servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!