2013-08-20 46 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問題或服務器問題。 –