html语言中文名称,html页面显示中文名称图片问题

页面的图片如果要求命名为中文时

blog_ad8a4f290102w0vz.html

解决方法1:

修改server.xml配置

加入URIEncoding=UTF-8

不过这种方法貌似不可行

解决方法2:使用过滤器​

在WEB-INF/web.xml配置

urlFilter

com.guanhuodata.framework.core.UrlFilter

DEFAULT_URI_ENCODE

UTF-8

​过滤器实现类

public class UrlFilter implements Filter {

public final static String DEFAULT_URI_ENCODE = "UTF-8";

private FilterConfig config = null;

private String encode = null;

public void init(FilterConfig config) throws ServletException

{

this.config = config;

this.encode = config.getInitParameter("DEFAULT_URI_ENCODE");

if (this.encode == null) {

this.encode = DEFAULT_URI_ENCODE;

}

}

public void doFilter(ServletRequest req, ServletResponse res,

FilterChain chain)

throws IOException, ServletException {

HttpServletRequest request = (HttpServletRequest) req;

String uri = request.getRequestURI();

String ch = URLDecoder.decode(uri, encode);

if (uri.equals(ch)) {

chain.doFilter(req, res);

return;

}

ch = ch.substring(request.getContextPath().length());

config.getServletContext().getRequestDispatcher(ch).forward(req,

res);

}

public void destroy() {

config = null;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值