SpringBoot+thymeleaf项目页面的一些问题
2017-03-28 11:19
615 查看
依然是在练习汪云飞版spring boot书籍遇到的一些小问题,出现在9.1.3实战部分(spring boot 下spring security的配置,完成简单认证授权),该实战例子中有两个页面,分别为登陆页面和首页,
问题1:例子中忘了说页面该放在哪个位置?
解决:翻看书本第7章,书中提到如果没有特殊说明,根据默认原则,页面应放置在src/main/resources/templates下,(当然都使用了maven),当你访问localhost:8080时,会自动映射该目录下的页面
问题2:首页文件叫什么名字?
解决:刚开始我以为默认叫index.html,然后访问就报错了Error resolving template "home", template might not exist or might not be accessible by anyof the configured Template Resolvers,然后我再仔细查看HomeController里面的代码:
@RequestMapping("/") public String index(Model model){ Msg msg=new Msg("测试标题","测试内容","额外信息,只对管理员显示"); model.addAttribute("msg",msg); return "home"; }
才发现,返回的视图名称是home,这下知道了首页文件名称home.html
相关文章推荐
- 在本地tomcat中调试Spring boot项目遇到的一些问题
- 使用eclipse构建springboot项目的解决的一些问题
- thymeleaf :springboot整合mybatis的web项目中使用html而不是jsp当页面渲染
- springboot项目打成war包部署到tomcat遇到的一些问题
- Spring项目的一些常见问题
- 使用spring boot 改造老项目,多个数据源问题
- springBoot+springSecurity+freemarker项目中页面获取当前登录用户
- spring boot 与dubbo 2.8.4整合的一些问题
- 奇葩问题:spring+mybaits项目突然出现其中一些Mapper类找不到
- spring boot创建项目包依赖问题
- springboot项目打包后运行出现问题解决办法
- Idea使用Maven创建多模块SpringBoot项目问题记录
- SpringBoot项目打包后,找不到文件路径问题,处理方法
- Spring-Boot1.4.0项目部署问题小记
- spring boot版本更新出现的一些问题
- 集成jcaptcha到spring-boot+maven项目中时出现java.lang.NoSuchMethodError: com.jhlabs.image.WaterFilter的问题的解决方法
- 基于maven的springMvc+Mybatis,搭建项目的时候发现一些问题这里例举下
- intellij idea2016 linux springboot项目下解决热部署问题
- 解决springboot项目打war 包docker包找不到resource 下的静态资源问题
- SpringBoot+Thymeleaf+iBatis开发项目