2009-12-22 62 views
-1

我用我的jsp页面编码问题JSP页

<% response.setContentType("application/xhtml+xml"); %> 

以下和网页正常显示,只是某些字符不正确地呈现,例如,在“版权”字符/符号。

不过,如果我使用:

<% response.setContentType("application/xhtml+xml;charset=UTF-8"); %> 

Internet Explorer的渲染页面的XML文档(XML树中显示),但好处是,所有字符都解决了,并正确显示。

任何人都可以对此有所了解吗?

谢谢。

+0

重复? http://stackoverflow.com/questions/1758270/displaying-xhtml-content-in-a-jsp-page – 2009-12-22 15:45:02

回答

1

下面是一个物品,其将解释在Java Web应用程序的角度看现象“统一”:Unicode - How to get the characters right?

这么说,我强烈建议你不要在JSP中使用小脚本。只需使用以下内容:

<%@ page pageEncoding="UTF-8" %> 
<!DOCTYPE whatever XHTML doctype you're using here> 
<html xmlns="whatever XHTML namespace you're using here"> 
    <head> 
     <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" /> 
     ... 

这应该足够了。