惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 疯蜂

Weblogic 页面404错误 WebLogic & MyEclipse 配置 (转)为什么我的网速越来越慢?如何限制迅雷偷偷上传文件? New year ,new scratch line,for the future - 疯蜂 ×××之品味寂寞 河北省××××××××××网总结 Java开发者需坚守的十大基本准则 Web 软件测试计划 我们的《测试报告》 国内主要的一些测试的网站汇总 测试? - 疯蜂 究竟什么才是真正的软件测试? 软件测试常用术语表 测试要点总结(转帖) 软件测试基本方法 I'm Back! 求助:C# WinForm C#导出Excel汇总 2007年暑期总结(李明锋)
Weblogic Server中如何解决中文显示乱码问题 - 疯蜂 - 博客园
疯蜂 · 2008-04-11 · via 博客园 - 疯蜂

由于操作系统、浏览器、数据库、JVM采用的字符集都不一样,基于Weblogic Server开发的应用经常出现中文显示乱码问题,其实在Weblogic Server上运行的WEB应用有很多与字符集有关的设置,下面做一个总结,为了正确处理中文,最好把这些设置都设上。
1. 在JSP文件头加入
<%@ page contentType="text/html; charset=GBK" %>
指定该JSP采用的字符集。

2.在Weblogic.XML文件的<jsp-descriptor>中加入:
<jsp-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</jsp-param>
指定JSP文件中采用的字符集,在JSP文件中的<%@ page contentType="text/html; charset=GBK" %>会覆盖该设置

3.在Weblogic.xml文件的<jsp-descriptor>中加入
<jsp-param>
<param-name>compilerSupportsEncoding</param-name>
<param-value>true</param-value>
</jsp-param>
如果为TRUE,指定在编译JSP文件时,采用在JSP文件中定义的
<%@ page contentType="text/html; charset=GBK" %>或<jsp-descriptor>中定义的encoding参数中定义的字符集进行编码,如果为FALSE,则采用JVM中默认指定的字符集进行编码。

4. Weblogic Server需要把HTTP request(GET 和POST)中的数据从它的原始编码转化为Unicode,以便Java Servlet API进行处理,为了做这种转换,Weblogic Server需要知道HPPT request中的数据的编码方式。这可以通过在Weblogic.xml的<context-param>中设置.
<input-charset>
<resource-path>/</resource-path>
<java-charset-name>GBK</java-charset-name>
</input-charset>

5.从Oracle数据库中检索出来的中文显示不正确时,在这种情况下,如果数据库使用的是中文字符集,并使用的是Type 2 JDBC Driver时,可加入Weblogic.codeset=GBK的属性来解决这个问题。代码如下:
java.util.Properties props = new java.util.Properties();
props.put("Weblogic.codeset", "GBK");
props.put("user", "scott");
props.put("password", "tiger");
String connectUrl = "jdbc:Weblogic:oracle";
Driver myDriver = (Driver)
Class.forName("Weblogic.jdbc.oci.Driver").newInstance();
Connection conn =
myDriver.connect(connectUrl, props);

6. 如果是采用WTC调用Tuxedo中的服务,在JSP页面中无法正确显示中文,必须使安装Tuxedo的服务器上的NLS_LANG环境变量与数据库中的字符集的设置一样。如后台Oracle数据库中的字符集设置为SIMPLIFIED CHINESE_CHINA.ZHS16GBK,那么Tuxedo应用服务器上的NLS_LANG环境变量应设置为:export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"