关键词:
springboot项目创建教程 https://blog.csdn.net/q18771811872/article/details/88126835
springboot2.0 跳转html教程 https://blog.csdn.net/q18771811872/article/details/88312862
springboot2.0 跳转jsp教程 https://blog.csdn.net/q18771811872/article/details/88342298
说明一下 。整合会遇到的问题,
1、pom.xml文件同时放入thymeleaf 架包和jsp支持后, springboot的return模版会默认跳转到html ,
那怕是你并没有配置thymeleaf的属性
解决方案, 使用getRequestDispatcher方法来跳转到jsp页面, 就同时支持html和jsp了
request.getRequestDispatcher("/WEB-INF/views/testJsp.jsp").forward(request, response);
2、另外 使用getRequestDispatcher跳转到html页面的时候,thymeleaf 模版接收参数可能会出现问题。
解决方案1:html放弃使用thymeleaf 模版,然后在页面主动请求接口数据(AJAX POST等)
解决方案2:html继续使用thymeleaf 模版,用return模版 返回来跳转页面
配置文件
pom.xml
以上就完了。
另外附加一个return 模版的java代码配置, 可以配置return模版的优先级,后面的文件格式,当然只能用getRequestDispatcher来跳转了
在启动类中添加,另外,配置文件参数和代码可重复 但是代码优先于配置文件。
/**
* 添加对jsp支持
*
*/
@Bean
public ViewResolver getJspViewResolver()
InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver();
internalResourceViewResolver.setPrefix("/WEB-INF/");//前缀
internalResourceViewResolver.setSuffix(".jsp");//后缀
internalResourceViewResolver.setOrder(0);//优先级
return internalResourceViewResolver;
/**
* 添加对Freemarker支持
*
*/
@Bean
public FreeMarkerViewResolver getFreeMarkerViewResolver()
FreeMarkerViewResolver freeMarkerViewResolver = new FreeMarkerViewResolver();
freeMarkerViewResolver.setCache(false);
freeMarkerViewResolver.setPrefix("/WEB-INF/");//前缀
freeMarkerViewResolver.setSuffix(".html");//后缀
freeMarkerViewResolver.setRequestContextAttribute("request");
freeMarkerViewResolver.setOrder(1);//优先级
freeMarkerViewResolver.setContentType("text/html;charset=UTF-8");
return freeMarkerViewResolver;
springboot项目创建教程 https://blog.csdn.net/q18771811872/article/details/88126835
springboot2.0 跳转html教程 https://blog.csdn.net/q18771811872/article/details/88312862
springboot2.0 跳转jsp教程 https://blog.csdn.net/q18771811872/article/details/88342298
springboot2.0之整合elasticsearch
就类比数据库到时候去实现服务器端配置集群名字 与yml名字一致pom:<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0ht 查看详情
springboot2.0之整合rabbitmq
案例: Springboot对RabbitMQ的支持公共的pom: <projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0 查看详情
springboot2.0整合fastjson的正确姿势(代码片段)
SpringBoot2.0如何集成fastjson?在网上查了一堆资料,但是各文章的说法不一,有些还是错的,可能只是简单测试一下就认为ok了,最后有没生效都不知道。恰逢公司项目需要将JackSon换成fastjson,因此自己来实践一... 查看详情
springboot2:springboot2.0新特性
SpringBoot2(一):SpringBoot2.0新特性SpringBoot依赖于Spring,而SpringCloud又依赖于SpringBoot,因此SpringBoot2.0的发布正式整合了Spring5.0的很多特性,同样后面SpringCloud最新版本的发布也需要整合最新的SpringBoot2.0内容。一、新版本特性1,基于J... 查看详情
springboot2.0整合freemarker快速入门
目录1.快速入门1.1创建工程pom.xml文件如下1.2编辑application.yml1.3创建模型类1.4创建模板1.5创建controller1.6测试2.FreeMarker基础2.1数据模型2.2List指令2.3遍历Map数据2.4if指令2.5运算符2.6空值处理2.7内建函数freemarker是一个用Java开发的模板引... 查看详情
springboot2.0应用:springboot2.0整合rabbitmq(代码片段)
如何整合RabbitMQ1、添加spring-boot-starter-amqp<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency>2、添加配置s 查看详情
springboot2.0.4整合springdatajpa和druid,双数据源
最近Team开始尝试使用SpringBoot+SpringDataJPA作为数据层的解决方案,在网上逛了几圈之后发现大家并不待见JPA,理由是(1)MyBatis简单直观够用,(2)以Hibernate为底层的SpringDataJPA复杂且性能一般。但是当我们来到SpringBoot的世界后发现,... 查看详情
springboot2.0.8跳转html页面
springboot项目创建链接 https://blog.csdn.net/q18771811872/article/details/88126835springboot2.0跳转jsp教程 https://blog.csdn.net/q18771811872/article/details/88342298jsp+html跳转整合 https://blog.csd 查看详情
springboot2.0源码分析:整合activemq分析(代码片段)
SpringBoot具体整合ActiveMQ可参考:SpringBoot2.0应用(二):SpringBoot2.0整合ActiveMQActiveMQ自动注入当项目中存在javax.jms.Message和org.springframework.jms.core.JmsTemplate着两个类时,SpringBoot将ActiveMQ需要使用到的对象注册为Bean,供项目注入使用... 查看详情
springboot2.0整合jpa
在整合的遇到各种坑,以下是我整合的流程1、pom.xml文件<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc</artifactId></dependency& 查看详情
springboot2.0整合mybatis
pom.xml<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </paren 查看详情
springboot2.0之整合redis
需要的maven依赖jar包,是对Jedis的封装maven依赖:<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://ma 查看详情
springboot2.0整合es的异常总结
异常:availableProcessorsisalreadysetto[4],rejecting[4]在启动类中加入System.setProperty("es.set.netty.runtime.available.processors","false");异常:org.elasticsearch.client.transport.NoNodeAvailableException:Noneof 查看详情
springboot2.0实战(23)整合redis之集成缓存springdatacache
SpringBoot2.0实战(23)整合Redis之集成缓存SpringDataCache来源:https://www.toutiao.com/a6803168397090619908/?timestamp=1584450221&app=news_article_lite&group_id=6803168397090619908&req_id=20200317210341 查看详情
springboot2.0+shiro+jwt整合(代码片段)
SpringBoot2.0+Shiro+JWT整合JSONWebToken(JWT)是一个非常轻巧的规范。这个规范允许我们使用JWT在用户和服务器之间传递安全可靠的信息。我们利用一定的编码生成Token,并在Token中加入一些非敏感信息,将其传递。安装环境开发工具:... 查看详情
学习整合springboot2.0和mybatis,实现基本的crud
前言:本文是在自己整合springboot2.0和mybatis时的过程和踩得坑。先附上github地址:https://github.com/yclxt/springboot-mybatis.git环境/版本:工具:IntellijIDEA2018.3JDK:1.8Springboot:2.0.4.RELEASEMybatis:1.3.2由于本人是初学者,对druid和handlePage不太熟 查看详情
springboot2.0之整合activemq(点对点模式)
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xs 查看详情
springboot2.0最新版相关技术
https://gitee.com/hejr.cn.com/SpringBoot2.0_2019/tree/master SpringBoot2.0最新版相关技术学习,该项目主要是提供给正在学习SpringBoot的小伙伴,包括整合Freemarker,JSP等web页面,以及数据访问,事务管理,日志管理,缓存(Ehcache,Redis)技术... 查看详情