1.配置文件application.properties,context-path:
上下文:
old: server.context-path=/thymeleaf (需要在地址栏中输入项目名访问 如:localhost:8080/thymeleaf/listCategory
new:server.servlet.context-path=/thymeleaf (localhost:8080/listCategory
使用上 new会方便很多 比如crud,不用输入thymeleaf
若使用旧的:
有时候会出现404(直接访问localhost:8080/editCategory去了)
很多时候都是程序反应问题,随便添加点注释多重启几下,把/删去添加,看看,基本是一致的 ,在自己的服务器上。
2.关于@RequestMapping的路径中的“/”:
众说纷纭,自己理解:
其中感觉有道理的是:
1.规范是需要加 / 的,如果前台访问的其他的,那么就势必找不到路径,这个是相对的路径(很多时候要注意规范,哪怕不报错,但是会提高很多可读性,以及兼容性)
https://segmentfault.com/q/1010000004934733 这个好像有点道理
https://bbs.csdn.net/topics/391490631
https://bbs.csdn.net/topics/392265390
https://ask.csdn.net/questions/658406?ref=myrecommend