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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
S
Securelist
博客园 - Franky
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
IT之家
IT之家
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
AI
AI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Schneier on Security
Schneier on Security
Attack and Defense Labs
Attack and Defense Labs
Vercel News
Vercel News
腾讯CDC
Google DeepMind News
Google DeepMind News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
Netflix TechBlog - Medium
量子位
S
Schneier on Security
Hacker News: Ask HN
Hacker News: Ask HN
Cyberwarzone
Cyberwarzone
S
Security Affairs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
News and Events Feed by Topic
T
Tenable Blog
PCI Perspectives
PCI Perspectives
MyScale Blog
MyScale Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
W
WeLiveSecurity
N
News | PayPal Newsroom
P
Proofpoint News Feed
O
OpenAI News
C
CERT Recently Published Vulnerability Notes
B
Blog
Cisco Talos Blog
Cisco Talos Blog
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Y
Y Combinator Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Spread Privacy
Spread Privacy

博客园 - dekn

如果做几十年的技术,不写点心得,是不是有点儿白瞎 如何修改tomcat内存大小 myeclipse中配置weblogic 9运行环境 解决无法向oracle中的long型字符插入大文本的问题 奇怪的JAVA字符集问题 让你的WEB程序同时支持FF与IE浏览器,经验积累 weblogic在处理jsp tag的scope属性时的BUG??? - dekn - 博客园 解决tomcat里中文文件无法正常下载 解决tomcat中rar、excel格式文件在下载时直接以乱码打开 test AJAX注意事项 WSAD与WebSphere中一步步配置JNDI 基于 Windows Mobile 的 Pocket PC 和 Smartphone 的开发工具简介 Windows CE .NET 应用程序开发:我有哪些选择? 开发 Windows Mobile 应用程序: FAQ 一天一个管理小故事 之二 《鲶鱼效应 》 一天一个管理小故事 之一 且慢下手 [原创]理解JNDI中 java:comp/env/jdbc/datasource 与 jdbc/datasource 的不同之处。 [详解]Linux的目录里都装些啥??
Tomcat中文问题小经验
dekn · 2006-07-12 · via 博客园 - dekn

一次开发中,遇到了很头大的中文问题,起初, 为了解决中文的参数传递问题,将/conf/server.xml中的编码设置为GBK,这时,中文的问题不存在了, 包括post  get数据也是正常的。 但是中文的文件却不能下载,每次访问中文的文件时,总是报“资源找不到”。 结果,在网上一查,有人说是将/conf/server.xml中的编码改成UTF-8。结果试了一下,果然OK。但这时,get方式提交表单或者URL中有中文时,又不能正常获取了。结果又改回到了GBK编码,通过以下方式解决中文文件下载的问题

<%
String fileUrl = java.net.URLEncoder.encode(search_result_info.getUrl(),"gbk");
fileUrl = cn.com.dekn.cms.util.StrUtil.replaceAll(fileUrl,"+"," ");
fileUrl = cn.com.dekn.cms.util.StrUtil.replaceAll(fileUrl,"%2F","/");
                               
%>
<a href="<%=fileUrl%>">

即使用 java.net.URLEncode 类对URL进行编码,编码为GBK, 而后在显示这个编码后的URL。 这个URL编码后,也baidu的方式是相同的。 但是JAVA的URLEncode将空格与/符号也进行了编码,似乎编码与浏览器采用的不一致,所以我在上面特别把空格与/去除,不对它们进行编码,编码后的 + 就是原先的空格,  %2F就是/ 。 后面打算继续彻底分析这个问题。 或者写一个适用的URLEncode类。