springboot

1、跳转页面

说道跳转,先说一下springBoot web的结构
其中static 中放的是可一直接访问的数据 ,比如[[InvalidCharacterError: "bold;"" did not match the Name production] 可以直接访问html templates 中放置的是跳转的数据
Springboot有自己默认的模板引擎。一定要引用相应的依赖包
org.springframework.boot spring-boot-starter-thymeleaf
这里注意:静态页面的return默认是跳转到/static/index.html,当在pom.xml中引入了thymeleaf组件,动态跳转会覆盖默认的静态跳转,默认就会跳转到/templates/index.html,注意看两者return代码也有区别,动态有或没有html后缀都可以。
跳转可以包含视图和数据
-------------------------------------------------------------------------------------------------------
ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("test1"); modelAndView.addObject("key", 12345); return modelAndView;
---------------------------------------------------------------------
上例可以跳转到test1视图中,并带上key值