今天做了一个URL下载的程序,发现文件名是%BD%CC%B3%CC 这种类型的,不知道怎么解析,后面查了下发现是GBK内码。。
请问下怎么把GBK内码转换成中文呢?
请问下怎么把GBK内码转换成中文呢?
解决方案 »
- 关于数据对象关联关系的疑惑
- 有如下需求,听听大家的想法
- 有没有用过开源的单点登录工具CAS的,利用CAS是否需要对各子系统进行一定的改造?
- Hibernate中could not insert问题?
- 按字母排序显示
- 如何用JS读写本地文本文件(不用ActiveXObject) 在线等 急
- 怎么样把数据库里的数据用树行结构显示出来
- request.setCharacterEncoding("gb2312")怎么用
- 各位大哥小小弟新学JSP想知道JSP想知道下面的代码是什么意思!那位大哥能给解释一下
- 我怎么在一个tomcat环境下配置两个系统,web-inf目录应放那里?
- HQl的couvert函数
- 伪静态
import javax.servlet.*; public class ChangeCharsetFilter implements Filter { protected String encoding = null;/////要制定的编码,在web.xml中配置 protected FilterConfig filterConfig = null;
public void destroy() {
this.encoding = null;
this.filterConfig = null;}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
if (request.getCharacterEncoding() == null){
String encoding = getEncoding();////得到指定的编码名字
if (encoding != null)
request.setCharacterEncoding(encoding);////设置request的编码
}
chain.doFilter(request, response);///有机会执行下一个filter
}
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");///得到在web.xml中配置的编码
} protected String getEncoding() {
return (this.encoding);///得到指定的编码
} }然后在web.xml中配置:<filter>
<filter-name>SetCharacterEncoding</filter-name>
<filter-class>ChangeCharsetFilter </filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SetCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>