IDEA搭建springboot注重细节(一)

一、只访问方法并返回某些值(非页面)

添加ResponseBody注解,方法访问注解RequestMapping("/访问名称"),如下图一中test()方法:结果在左侧

二、访问方法并返回指定页面

页面路径配置不能错:index的路径就在jsp下,所以配置中的路径必须为/WEB-INF/JSP/,才能准确返回index页面。

如下图,testDemo()方法,返回值必须为页面名称index,否则报错找不到页面。

假如:更改页面配置路径为/WEB-INF/,则testDemo()方法,返回值必须为页面名称index2,否则报错找不到页面。

 搭建springboot参考路径:https://www.cnblogs.com/gen9201117/p/9360805.html

每天涨点小知识~~~

原文地址:https://www.cnblogs.com/mangwusuozhi/p/13215827.html