【发布时间】:2014-08-26 15:51:54
【问题描述】:
我开发了一个应用程序,该应用程序部署到一个也托管其他应用程序的 tomcat 实例。为此,端口 80 上的连接器将其 URIEncoding 设置为“UTF-8”。我想找到一种方法来为我的 servlet 覆盖此设置,而无需在另一个端口上指定另一个连接器。我试过使用tomcat过滤器来设置过滤器如下:
@Override
public void doFilter(final ServletRequest request, final ServletResponse response,
final FilterChain filterChain) throws IOException, ServletException {
request.setCharacterEncoding(encoding);
filterChain.doFilter(request, response);
}
但它不会改变任何东西。我的 ISO-8859-1 编码字符串在进入 servlet 时包含意外字符。
【问题讨论】:
标签: java servlets utf-8 tomcat6 iso-8859-1