当前位置:编程学习 > C/C++ >>

ajax 传后台中文 怎么处理

答案:
public class ActionServletToGB2312 extends ActionServlet {

protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html;charset=GB2312");

request.setCharacterEncoding("GB2312"); //只需换编码即可
super.process(request, response);
}

}

在web.xml里配下
<servlet-name>action</servlet-name>
<servlet-class>com.zsingsoft.bean.ActionServletToGB2312</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>market</param-value>
<!-- 默认资源文件名 -->
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

上一个:零基础学Java Web开发:JSP+Servlet+Struts+Spring+Hibernate+Ajax(第2版)
下一个:一段c++代码

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,