SpringBoot不使用模板引擎直接返回html
2024-08-26 13:53:12
一、在resource目录下面建立文件夹,里面方静态页面。
路径:src\main\resources\static\page\index.html
访问:http://localhost:8080/page/index.html
注意:后缀一定要html或者htm,否则打不开。
二、Spring Controller返回页面
访问:http://localhost:8080/index
注意:前端不能获取后台传递值,因为html不支持EL表达式。jsp或者模板引擎才支持
@Controller
public class HelloController { @RequestMapping("/index")
public String index(){
System.out.println("coming......");
return "page/index.html";
} @RequestMapping("/index2")
public ModelAndView index2(ModelAndView modelAndView){
System.out.println("coming......");
modelAndView.addObject("name","tom");
modelAndView.setViewName("page/index.html");
return modelAndView;
} }
最新文章
- linux开启telnet
- 在 远程桌面 权限不足无法控制 UAC 提示时,可使用 计划任务 绕开系统的 UAC 提示
- session 实现保存用户信息
- ApplicationIdle
- 重写session
- sql join 用法
- Nexus 刷机
- 2014第6周五JS调试
- Weblogic 部署注意事项
- HRBUST1522【单调队列+DP】
- vue+cordova 构建hybrid app
- C++对象模型的那些事儿之二:对象模型(下)
- 磁盘挂载问题:Fdisk最大只能创建2T分区的盘,超过2T使用parted
- 【凸包板题】Gym - 101484E E. Double Fence
- 20170915 shell
- ubuntu下没有ping命令
- 关于cookie和session
- IOS网络篇1之截取本地URL请求(NSURLProtocol)
- 洛谷P1083 借教室 NOIP2012D2T2 线段树
- JBPM4.4_管理流程定义