08/02/14 22:19:27
>>614
こんなフィルタ作ってみたんだけどダサいかな?突っ込みキボンヌ。エロイ人。
public class SessionFilter extends FilterDispatcher {
@Override
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpReq = (HttpServletRequest) req;
String userId = (String) httpReq.getSession().getAttribute("userId");
if (StringUtils.isEmpty(userId)) {
if (!httpReq.getServletPath().equals("/login.action")
&& !httpReq.getServletPath().equals("/login!input.action")) {
((HttpServletResponse) res).sendRedirect("login!input.action");
return;
}
}
super.doFilter(req, res, chain);
}
}