display special characters in jsp page

ⅰ亾dé卋堺 提交于 2020-01-21 12:15:14

问题


How to display right content on jsp page or any configuration need to done in tomcat server...?

display at jsp : Hello G�nter

original content : Hello Günter

We do the following but its not working.

 <%@ page language="java" contentType="text/html; charset=ISO-8859-15"   
     pageEncoding="UTF-8"%>

回答1:


As most other people have said, you should probably check the encoding of the actual file on the file system. Even if the server is instructed to serve out UTF-8, if the file is mangled, you'll get the wrong output.

Among the most common tools, you can use Notepad++ or Eclipse to check the encoding of the file. In Notepad++, open the file and click the Encoding tab. Make sure that "Encode as UTF-8" is selected.

In eclipse, you need to right-click the file in the project explorer. In the Resource tab, the bottom property is "Text file encoding". Make sure that UTF-8 is selected there.


FYI, I had a similar encoding issue a while ago, on Weblogic. The order of the parameters in the attributes affected the way the page behaved. You can find more info here, although I don't think it applies to your problem.




回答2:


  1. If on Windows, install additional language pack.
  2. Save the JSP file encoded in UTF-8.
  3. Make charset and pageEncoding consistent.
  4. Check your browser's encoding. Set it to UTF-8 as well.



回答3:


  • If it is hard-coded HTML use HTML escape sequences.
  • If the value is being picked up from a ResourceBundle, use unicode equivalents.



回答4:


Eclipse defaults to your platform encoding when saving files. If you are on windows, this will most likely not be UTF-8. To change this, either right-click the file (jsp) in eclipse, click properties and at the bottom you can set the encoding it saves the file in.

To change the default content type in Eclipse, you can go to Windows->Preferences and under General / Content Types you can set default encoding to save as for different file types.




回答5:


Your jsp page is OK. So make sure your browser's character encoding is UTF-8.



来源:https://stackoverflow.com/questions/11842215/display-special-characters-in-jsp-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!