idea tomcat springMVC restful 结果页面显示“源服务器未能找到目标资源的表示或者是不愿公开一个已经存在的资源表示。

问题遇到的现象和发生背景

img

img

img

img

//控制器
@Controller
public class RustFullController {
    @RequestMapping("/commit/{a}/{b}")
    public String test(@PathVariable int a, @PathVariable int b,Model model){
        int res=a+b;
        model.addAttribute("msg","结果:"+res);、
       //返回视图
        return "test";
    }
}
<!--resources文件-->
    <context:component-scan base-package="com.controller"/>
       <mvc:default-servlet-handler/>
       <mvc:annotation-driven/>
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
         id="internalResourceViewResolver">
       <property name="prefix" value="/WEB-INF/jsp/"/>
       <property name="suffix" value=".jsp"/>
   </bean>
最后页面显示404,不是预计的“结果:5”

404是没有找到资源。
你返回的是“test”,test.jsp文件在jsp目录下,改为:“jsp/test”试试。

img

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632