Add the following code to the 1.web.xml configuration:
<?XML version= "1.0" encoding= "UTF-8"?><Web-appXmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns= "Http://java.sun.com/xml/ns/javaee"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"ID= "webapp_id"version= "2.5"> <Display-name>Springmvc</Display-name> <servlet> <Servlet-name>Spring</Servlet-name> <Servlet-class>Org.springframework.web.servlet.DispatcherServlet</Servlet-class> <Load-on-startup>1</Load-on-startup> </servlet> <servlet-mapping> <Servlet-name>Spring</Servlet-name> <Url-pattern>/</Url-pattern> </servlet-mapping> <Filter> <Filter-name>Encodingfilter</Filter-name> <Filter-class>Org.springframework.web.filter.CharacterEncodingFilter</Filter-class> <Init-param> <Param-name>Encoding</Param-name> <Param-value>UTF-8</Param-value> </Init-param> <Init-param> <Param-name>Forceencoding</Param-name> <Param-value>True</Param-value> </Init-param> </Filter> <filter-mapping> <Filter-name>Encodingfilter</Filter-name> <Url-pattern>/*</Url-pattern> </filter-mapping></Web-app>
2.xxx-servlet.xml, add the following code to the <beans> tag:
<BeanID= "Velocityconfigurer"class= "Org.springframework.web.servlet.view.velocity.VelocityConfigurer">< Propertyname= "Resourceloaderpath"><value>web-inf/vm/</value></ Property>< Propertyname= "Velocityproperties"><Props><propKey= "Input.encoding">UTF-8</prop><propKey= "Output.encoding">UTF-8</prop></Props></ Property></Bean><BeanID= "Vmviewresolver"class= "Org.springframework.web.servlet.view.velocity.VelocityViewResolver">< Propertyname= "Cache"value= "true" />< Propertyname= "prefix"value="" />< Propertyname= "suffix"value= ". VM" />< Propertyname= "Order"value= "1" />< Propertyname= "ContentType"value= "UTF-8"/></Bean>
3.XX.VM file, add the following code to the
<http-equiv= "Content-type" Content= "text/html; Charset=utf-8" >
4. Garbled Solution!
Velocity Chinese garbled processing in the integrated spring MAVEN project