中文等特殊字符参数传递乱码
一、JSP TO JSP
??如果改用get则刚好相反
?
2、使用编码函数
?package com.yourcompany.struts.action;import java.io.UnsupportedEncodingException;import java.net.URLDecoder;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import com.yourcompany.struts.form.TestForm;public class TestAction extends Action {public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {TestForm testForm = (TestForm) form;response.setCharacterEncoding("UTF-8");String name=testForm.getName();String pwd=testForm.getPwd();response.setCharacterEncoding("UTF-8");String myname=request.getParameter("myname");myname=URLDecoder.decode(myname, "UTF-8");String mypwd=request.getParameter("mypwd");mypwd=URLDecoder.decode(mypwd, "UTF-8");System.out.println(name);System.out.println(pwd);System.out.println(myname);System.out.println(mypwd);request.setAttribute("name", name);request.setAttribute("pwd", pwd);request.setAttribute("myname", myname);request.setAttribute("mypwd", mypwd);return mapping.findForward("go");}}??
?
?
?