在Spring Boot中配置concat url

时间:2019-10-14 10:30:02

标签: spring-boot spring-mvc

我想在请求后连接我当前的网址,

我的代码:

@RequestMapping(value = "/individual")
    public ModelAndView home2(ModelAndView modelAndView,HttpServletRequest request,ServletResponse response,FilterChain chain) throws ServletException, IOException {
        HttpServletRequest httpServletRequest = ((HttpServletRequest) request);
        String requestURI = httpServletRequest.getRequestURI();

        request.getRequestDispatcher(requestURI.concat("/IN"))
        .forward(request,response);

        modelAndView.setViewName("login");
        return modelAndView;
    }

预期投放:

localhost:8080/individual/IN

错误:

2019-10-14 15:58:44.000 ERROR 8752 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.FilterChain]: Specified class is an interface] with root cause

org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.FilterChain]: Specified class is an interface
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:99) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]

我也在拦截器中尝试过,但是没有用:-

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        requestURI = request.getRequestURI();
        String newRequestURI = requestURI.concat("EN/");
        request.getRequestDispatcher(newRequestURI).forward(request, response);
        return true;
    }

0 个答案:

没有答案