2013-08-20 120 views
0

我有两个jsp页面。我正在尝试添加“俄语”语言。俄语字符在jsp页面上完美显示,但是当我尝试将此值从参数发送到另一个jsp页面时,则在第二个jsp页面中,此值将更改为不同的字符。这个问题只有俄语,而不是意大利和法国等其他国家。JSP编码器问题在QueryString中发送俄罗斯字符

例如

On demo.jsp page the russian character "приветствие" is shown correctly. 
but when I try to send it to another page "test.jsp" then some unknown 
characters are shown like "!C<Cä5 Cô>CôCC´OD=Cä5!" 

代码: demo.jsp

String welcometext=langP.get("welcome"); 

<jsp:include page="<%=test.jsp%>"> 
<jsp:param name="wlc" value="<%=Encode.hex8Code(welcometext)%>" /> 
</jsp:include> 

在test.jsp的

String title = Encode.utfToUnicode(Decode.hex8Decode(request.getParameter("wlc"))); 
System.out.println(" Russial welcome test "+welcome); 

是否有我们需要增加对俄罗斯在发送任何特殊代码他们在查询参数?

请注意*下面的代码已经编写否则将给予法国和意大利的语言太多的问题..

<%@ page contentType="text/html; charset=UTF-8" %> 
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> 

与以下也试过,但没有帮帮忙!

request.setCharacterEncoding("UTF-8") 

回答

0

我不知道如此好但下面的代码解决了这个问题。我保持会话属性中的变量。

demo.jsp

session.setAttribute("welcometext", welcometext); 

test.jsp的

String welcometest=(String) session.getAttribute("welcometext"); 
0

尝试添加<% request.setCharacterEncoding("UTF-8"); %>到您的主jsp页面:

这是我的例子:

demo.jsp

<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
<% request.setCharacterEncoding("UTF-8"); %> 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>JSP Page</title> 
    </head> 
    <body> 
     <h1>Привет</h1> 
     <jsp:include page="/test.jsp" flush="true"> 
      <jsp:param name="wlc" value="Привет"/> 
     </jsp:include> 
    </body> 
</html> 

test.jsp的

<h1>Param values is</h1> 
    <% 
     String hello = request.getParameter("wlc"); 
     out.print(hello); 
    %> 
+0

@Alexey ... Nopes。我试着把它放在我的主JSP页面上,然后重新启动Tomcat ..但同样的问题! –

+0

@MadanMadan你有没有尝试删除所有的解码和编码方法?试试我干净的例子来了解它是否是jsp问题或服务器问题。 –