problem
The project requires that the STRUTS2 and servlet coexist, that struts requests are sent to struts, and that the servlet request is sent to the servlet for processing. The current Web.xml file should be a configuration similar to the following:
<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>
When the application is requested, STRUTS2 will intercept all requests and will not be able to respond properly to the servlet request, because struts2 the servlet as an action because the servlet and action have no suffixes. solution (four ways) 1. Modify the related configuration of the servlet and unify the ". servlet" Behind the servlet
1). Modify the Web.xml profile like this:
<servlet>
<servlet-name>jqueryAjaxServlet</servlet-name>
<servlet-class> com.clzhang.sample.struts2.servlet.jqueryajaxservlet</servlet-class>
</servlet>
< servlet-mapping>
<servlet-name>jqueryAjaxServlet</servlet-name>
<url-pattern>/ Servlet/jqueryajax.servlet</url-pattern>
</servlet-mapping>
2. Modify the place where the servlet is invoked, in the form of:
<%
String Path = Request.getcontextpath ();
%> ...
$.ajax ({
URL: ' <%=path%>/servlet/jqueryajax.servlet ',
...)
This allows the servlet's request to be handled properly. This situation is appropriate for small-scale use of the servlet. 2. Modify the blocking page configuration, that is, the relevant interception of struts configuration
Modify the Web.xml file as follows:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</ url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</ Filter-name>
<url-pattern>*.do</