springboot 整合web项目支持jsp
2017-04-26 17:51
567 查看
1.pom文件 加入下面依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- servlet依赖. --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency> <!-- JSTL(JSP Standard TagLibrary,JSP标准标签库)是一个不断完善的开放源代码的JSP标签库,是由apache的jakarta小组来维护的。JSTL只能运行在支持JSP1.2和Servlet2.3规范的容器上,如tomcat 4.x。在JSP2.0中也是作为标准支持的。 不然报异常信息: javax.servlet.ServletException:Circular view path [/helloJsp]: would dispatch back to the current handler URL[/helloJsp] again. Check your ViewResolver setup! (Hint: This may be the resultof an unspecified view, due to default view name generation.) --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> <!-- tomcat的支持.--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <!--<scope>provided</scope>--> </dependency>
2.修改application.properties
加入下面配置# 页面默认前缀目录 spring.mvc.view.prefix=/WEB-INF/view/ # 响应页面默认后缀 spring.mvc.view.suffix=.jsp
3.webapp/WEB-INF目录下新增view目录
添加自已的jsp文件4.编写Controller
@Controller public class HelloController { @RequestMapping("/he") public String say(Map<String,Object> map){ map.put("hello","haha"); return "hello"; } }
5.启动springboot应用
6.浏览器访问http://127.0.0.1:8080/he
注意:如有遇到启动报错,请仔细检查pom文件和application.properties文件是否配置正确?源码示例,建议自己动手之后参照示例
https://github.com/MrZhengliang/springboot-jsp
源码下载,
http://download.csdn.net/detail/xinteng2012/9827291
相关文章推荐
- thymeleaf :springboot整合mybatis的web项目中使用html而不是jsp当页面渲染
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- 【spring boot】5.spring boot 创建web项目并使用jsp作前台页面
- 基于springBoot整合传统jsp项目
- springboot学习(二)springboot项目整合前端,添加jsp的访问
- Web项目下整合springBoot+springMVC+mybatis+boot内嵌tomcat以及所需jar包
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- springboot 在idea多模块下 子模块的web项目用内置tomcat启动访问jsp报404
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- springboot之web项目开发(spring+jpa+jsp)
- spring boot创建web项目:新建jsp文件而找不到jsp文件模版的新建选项
- SpringBoot web jsp项目打包成war
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- Spring Boot项目添加jsp支持
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- web项目中加入struts2、spring的支持,并整合两者
- spring boot 学习笔记(二) 构建web支持jsp
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持