@WebFilter(filterName = "LoginFilter",
value = "/*",
initParams = {
@WebInitParam(name = "noLoginPaths", value = "login.jsp;fail.jsp;LoginServlet"),
@WebInitParam(name = "charset", value = "UTF-8")
})
value = "/*",
initParams = {
@WebInitParam(name = "noLoginPaths", value = "login.jsp;fail.jsp;LoginServlet"),
@WebInitParam(name = "charset", value = "UTF-8")
})
2017-08-29
本课在servlet3.0 中使用注解的方式配置是:
@WebFilter(filterName = "LoginFilter",
value = "/success.jsp",
initParams = {
@WebInitParam(name = "noLoginPaths", value = "login.jsp;fail.jsp;LoginServlet")
})
@WebFilter(filterName = "LoginFilter",
value = "/success.jsp",
initParams = {
@WebInitParam(name = "noLoginPaths", value = "login.jsp;fail.jsp;LoginServlet")
})
new String(username.getBytes("ISO-8859-1"),"UTF-8"); //改变字符串的编码
request.setCharacterEncoding("UTF-8");
也可以直接在过滤器中设置 charset = "UTF-8";
request.setCharacterEncoding("UTF-8");
也可以直接在过滤器中设置 charset = "UTF-8";
2017-08-28
过滤器的生命周期和Servlet的生命周期类似,都是起始于服务器启动,终于服务器关闭。
过滤器的生命周期
1. 实例化:启动服务器时加载过滤器的实例
2. 初始化:调用init()方法来初始化实例
3. 执行过滤:doFilter
4. 销毁:服务器关闭时调用destory()方法进行销毁
过滤器的生命周期
1. 实例化:启动服务器时加载过滤器的实例
2. 初始化:调用init()方法来初始化实例
3. 执行过滤:doFilter
4. 销毁:服务器关闭时调用destory()方法进行销毁
2017-08-28
过滤器和拦截器是不同的,过滤器基于servlet,拦截器基于Spring MVC。可以看一下这篇博客。http://blog.csdn.net/chenleixing/article/details/44573495
2017-08-28