Créez un filtre pour le contenu en double pour rendre votre code plus propre! !! !!
EncodingFilter.java
package tool;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
@WebFilter(urlPatterns = { "/*" })
public class EncodingFilter implements Filter {
public void doFilter(
ServletRequest request,
ServletResponse response,
FilterChain chain
) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
System.out.println("Avant de filtrer");
chain.doFilter(request, response);
System.out.println("Après filtrage");
}
public void init(FilterConfig filterconfig) {}
public void destory() {
}
}
Recommended Posts