首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >filter过滤器此URL不支持HTTP状态405-HTTP方法GET?

filter过滤器此URL不支持HTTP状态405-HTTP方法GET?

提问于 2019-07-12 10:46:33
回答 0关注 0查看 333

我写了一个过滤器如下:

代码语言:javascript
复制
@WebServlet(urlPatterns = {"/jsp/buy/buy-uploadlist.jsp", "/jsp/buy/buy-buylist.jsp"})
public class LoginValidationFilter extends HttpServlet {
    protected FilterConfig filterConfig;
    public LoginValidationFilter() {
    }

    private String encode = "UTF-8";// 默认UTF-8编码

    
    protected void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        //request.setCharacterEncoding("UTF-8");
        HttpServletRequest req = (HttpServletRequest)request;
        HttpServletResponse resp = (HttpServletResponse)response;
        HttpSession session = req.getSession();
        PrintWriter out = response.getWriter();
        String reqURL = req.getServletPath();
        String loginMess = (String)session.getAttribute("login");
        if(loginMess == null || !loginMess.equals("true")){
            resp.sendRedirect(req.getContextPath() + "/visiterror.jsp");
            return;
        }
        chain.doFilter(request,response);
    }


    public void init(FilterConfig fConfig) throws ServletException{
        this.filterConfig = fConfig;
    }
}

然后启动TOMCAT在尝试访问这两个页面是始终提示”405此URL不支持Http方法GET“,我在网上查到的重写方法没有效果,请问可能是什么原因?非常感谢

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档