passer1991

utf8和UTF-8的不同 不同web程序之间的传值

utf8和UTF-8的不同,像下面这种情况,就要用UTF-8,而mysql中可能有要用到utf8

struts2base1

	@Action(value="m3",results={@Result(name="method3",type="redirect",location="${url}")})
	public String method3() throws IOException
	{
		String username="中国";
		username=URLEncoder.encode(username,"UTF-8");
		this.url="http://localhost:8080/struts2base2/1.jsp?username="+username;
		System.out.println(url);
		return "method3";
	}	

struts2base2  1.jsp

   <%=(String)request.getAttribute("username") %><br/>
 <%
		String username=request.getParameter("username");
		 username=new String(username.getBytes("ISO8859-1"),"UTF-8");
		out.println("Parameter   "+username);
 %>

  

 

posted on 2013-03-31 00:01  passer1991  阅读(210)  评论(0编辑  收藏  举报

导航