日期:2014-05-17 浏览次数:20674 次
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<h2>GET</h2>
<s:form action="test.action" method="get">
<s:textfield name="user.userName"></s:textfield>
<s:password name="user.password"></s:password>
<s:submit value="提交"></s:submit>
</s:form>
<hr/>
<h2>POST</h2>
<s:form action="test.action" method="post">
<s:textfield name="user.userName"></s:textfield>
<s:password name="user.password"></s:password>
<s:submit value="提交"></s:submit>
</s:form>
<constant name="struts.il8n.encoding" value="UTF-8"></constant>
public class CharacterEncodingFilter implements Filter {
/**
* 专门写的转码用(UTF-8),防止中文乱码
*/
@Override
public void destroy() {
// TODO Auto-generated method stub
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
chain.doFilter(request, response);
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub
}
public class CharacterEncodingFilter extends HttpServlet implements Filter {
/**
* 专门写的转码用(UTF-8),防止中文乱码
*/
@Override