webapp的子文件夹下的html如何访问到Java的controller层方法 ?
+webapp
+pages
index.html
场景: webapp 下有pages,pages下有html, html 要访问java的src的某个方法(category下的getAllCategory方法),实现如下:
$.getJSON("/tou_tiao_war_exploded/category/getAllCategory",function (json) {
console.log(json)
})
说白了,解决方法就是在路径前记得加上 “/”+工程名 即可。如果你是jsp文件,用EL表达式获取工程名在拼接上方法路径也可以。