警告o.s.web.servlet.PageNotFound - 没有找到带URI的HTTP请求的映射?

时间:2017-06-30 10:42:02

标签: spring http-status-code-404

我在我的sping控制器类中使用了@RestController。    它在api调用的情况下运行正常,当我使用modelandview呈现它给出上面的视图页面时   在这里输入代码WARN o.s.web.servlet.PageNotFound - 找不到带URI的HTTP请求的映射

 My web.xml 

<bean               class=
  "org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/pages/" />
    <property name="suffix" value=".jsp" />
</bean>

<servlet>
    <servlet-name>cardreaderapp</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>cardreaderapp</servlet-name>
    <url-pattern>/*</url-pattern>
 </servlet-mapping>`enter code here`
 </web-app>

 My Controller class

  @RestController
   public class BasicController {
 @RequestMapping("/")
  public ModelAndView test()
    {
   System.out.println("Controller class invoked");
   return new ModelAndView("index");
}
 and my view exist at following location
webapp->web-INF->pages->index.jsp

0 个答案:

没有答案