成熟

意味着重新获得儿时玩耍的一本正经样儿。

CharacterEncodingFilter.java以及修改web.xml所用代码

package com.alavey.example;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class CharacterEncodingFilter implements Filter {

    public void destroy() {

     }


    public void doFilter(ServletRequest request, ServletResponse response,
                                   FilterChain chain) throws IOException, ServletException {
         request.setCharacterEncoding("utf-8");
         chain.doFilter(request, response);
     }

    public void init(FilterConfig arg0) throws ServletException {
     }

}




<filter>
      <filter-name>characterEncoding</filter-name>
      <filter-class>com.alavey.example.CharacterEncodingFilter</filter-class>
</filter>


<filter-mapping>
      <filter-name>characterEncoding</filter-name>
      <url-pattern>/*</url-pattern>
</filter-mapping>

阅读更多
文章标签: filter class
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭