标签:注释 imp text att ping config har content tty
做一个字符编码过滤器.注册xml后,Tomcat启动web项目提示如下错误信息 :
org.apache.catalina.core.StandardContext.startInternal 一个或多个筛选器启动失败。
将web.xml
中的注册信息注释项目能正常运行,所以怀疑是过滤器的问题
package com.shme.filter;
import javax.servlet.*;
import java.io.IOException;
/**
* @Desc 字符编码过滤器
*/
public class CharacterEncodingFilter implements Filter{
@Override
public void init(FilterConfig filterConfig) throws ServletException {
System.out.println("CharacterEncodingFilter过滤器初始化");
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
//设置utf-8
request.setCharacterEncoding("utf-8");
response.setContentType("text/html");
response.setCharacterEncoding("utf-8");
chain.doFilter(request,response);
}
@Override
public void destroy() {
System.out.println("CharacterEncodingFilter过滤器销毁");
}
}
<!--字符编码过滤器-->
<filter>
<filter-name>charset</filter-name>
<filter-class>com.shme.filter.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>charset</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
标签:注释 imp text att ping config har content tty
原文地址:https://www.cnblogs.com/shmebluk/p/13191821.html