Web. xml files generally include servlet, spring, filter, and listenr configuration.
Loading Order will affect spring bean calls.
Listener> filter> servlet> spring
If bean is used in the filter, you can change spring loading to listener.
<Listener>
<Listener-class>
Org. springframework. Web. Context. contextloaderlistener
</Listener-class>
</Listener>
Their internal execution sequence should also be noted.
Garbled characters caused by the filter execution sequence of Web. xml
The cause of the bug is the following lines of Web. xml:
<Filter-mapping>
<Filter-Name> securityfilter </filter-Name>
<URL-pattern> *. DO </url-pattern>
</Filter-mapping>
<Filter-mapping>
<Filter-Name> characterencoding </filter-Name>
<URL-pattern> *. DO </url-pattern>
</Filter-mapping>
<Filter-mapping>
<Filter-Name> characterencoding </filter-Name>
<URL-pattern> *. jsp </url-pattern>
</Filter-mapping>
According to the servlet2.3 specification, filter execution is performed according to the Web. the filter-mapping configured in XML is executed sequentially, so the above configuration will result in *. do URL requests are first processed by the securityfilter filter. At this time, no encoding is performed, and garbled characters are generated. It is useless to process the following filters.
Modify the filter-mapping order as follows:
<Filter-mapping>
<Filter-Name> characterencoding </filter-Name>
<URL-pattern> *. DO </url-pattern>
</Filter-mapping>
<Filter-mapping>
<Filter-Name> characterencoding </filter-Name>
<URL-pattern> *. jsp </url-pattern>
</Filter-mapping>
<Filter-mapping>
<Filter-Name> securityfilter </filter-Name>
<URL-pattern> *. DO </url-pattern>
</Filter-mapping>