1.将视图文件放在resource的templates目录下
2. 第二步在application.properties配置文件中添加
#访问静态视图的路径
spring.thymeleaf.prefix=classpath:/templates/
spring.resources.static-locations=classpath:/templates/
注意:首页的index.html文件必须放在templates/根下
3.运行项目,打开浏览器输入localhost:8080。
如果光输入localhost:8080打不开首页,就换成localhost:8080/index.html试试
4.要达开html文件夹下的文件,可以这样输入
localhost:8080/html/xxx.html
5.在这个环境下,ajax的url请求就可以省略掉前缀了
$.ajax({
type : 'post',
url : 'http/addRace',
contentType : 'application/json;charset=utf-8',
data:formdata,
success : function(status){
if(status==1){
alert("添加成功!");
//initStudentTable();
}else{
alert("添加失败!");
}
}
});
6.然后就可以快乐的开发你的web项目了