spring和struts的集成

 

import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.struts.DelegatingTilesRequestProcessor; public class EncodingProcessor extends DelegatingTilesRequestProcessor{ @Override public void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { request.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8"); super.process(request, response); } }

struts-config.xml

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/> </plug-in> <!-- 自定义RequestProcessor,用于解决和Spring的集成和汉字乱码问题 --> <controller processorClass="EncodingProcessor"/>

web,xml

<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <servlet> <servlet-name>context</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet>

 

你可能感兴趣的:(spring,xml,struts,servlet,Class,import)