Create a project, such as Struts2
All the jar files in the Struts-2.0.6lib (for later extensions) are pasted into the project Struts2 Lib directory.
Second, the web.xml of the configuration project
Struts2.0 all configurations are integrated into a filter, which is located in Org.apache.struts2.dispatcher.FilterDispatcher, so it should be declared in Web.xml:
<filter>
<filter-name>struts</filter-name>
<filter-class>
Org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
However, the filter a problem, that is, from the page to the background of Chinese after this filter will become garbled, in order to solve this problem, need to rewrite this filter, the simplest way is to write a class inherited Filterdispatcher, Create the Com.filter package in the SRC directory, set up the Newfilterdispatcher class in the package, inherit the Filterdispatcher, code as follows:
Package com.filter;
Import java.io.IOException;
Import Javax.servlet.FilterChain;
Import Javax.servlet.FilterConfig;
Import javax.servlet.ServletException;
Import Javax.servlet.ServletRequest;
Import Javax.servlet.ServletResponse;
Import Org.apache.struts2.dispatcher.FilterDispatcher;
public class Newfilterdispatcher extends Filterdispatcher {
private static String encoding = "GB2312";
public void init (Filterconfig filterconfig) throws Servletexception {
Super.init (Filterconfig);
String Encodingparam = filterconfig.getinitparameter ("encoding");
if (Encodingparam!= null && encodingparam.trim (). Length ()!= 0) {
encoding = Encodingparam;