URLパターンでServletFiltersを使用しているときに、jspページで画像を取得できません。私のウェブページで画像を取得できるように助けてください.
フィルタ コード:
package com.peckuk.filter;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
public class AdminFilter implements javax.servlet.Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
String test = filterConfig.getInitParameter("test-param");
System.out.println("Init Method" + test);
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
PrintWriter out = response.getWriter();
System.out.println("doFilter Method");
HttpServletRequest req = (HttpServletRequest) request;
HttpSession session = req.getSession();
String role = session.getAttribute("role").toString();
if (role.equals("admin")) {
chain.doFilter(request, response);
} else {
out.println("Invalid user role");
}
}
@Override
public void destroy() {
System.out.println("destroy Method");
}
}