Spring boot 添加jsp模版支持
来源:互联网 发布:新网络武侠小说排行榜 编辑:程序博客网 时间:2024/06/07 07:39
Spring boot 添加jsp模版支持
1.0包结构如图:
2.0在pom.xml中加入如下配置:
<?xml version="1.0" encoding="UTF-8"?><project xmlns="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.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.yidigis</groupId> <artifactId>wechat-system</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>wechat-system</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.7.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--jpa的jar包 ,操作数据库的,类似hibernate --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <!--mysql驱动 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!--配置servlet--> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> </dependency> <!--配置jsp jstl的支持--> <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> <!--对jsp的支持--> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!--fork : 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart --> <fork>true</fork> </configuration> </plugin> </plugins> </build></project>3.0编写application.properties配置文件;
server.port=80# 页面默认前缀目录 默认路径是 src/main/webappspring.mvc.view.prefix=/WEB-INF/jsp/# 响应页面默认后缀spring.mvc.view.suffix=.jsp# 自定义属性,可以在Controller中读取application.hello=Hello Angel From application###########################################################datasource -- 指定mysql数据库连接信息.########################################################spring.datasource.url = jdbc:mysql://localhost:3306/testspring.datasource.username = rootspring.datasource.password = rootspring.datasource.driverClassName = com.mysql.jdbc.Driverspring.datasource.max-active=20spring.datasource.max-idle=8spring.datasource.min-idle=8spring.datasource.initial-size=104.0编写controller控制器
package com.yidigis.controller;import org.springframework.beans.factory.annotation.Value;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import java.util.Map;@Controller@RequestMappingpublic class hellocontroller { @Value("${application.hello:Hello Angel}") private String hello; @RequestMapping("/") public String welcome(){ return "index"; } @RequestMapping("/hello") public String helloJsp(Map<String,Object> map){ System.out.println("HelloController.helloJsp().hello="+hello); map.put("hello", hello); return "/seller/hello"; }}5.0 编写jsp页面:
<%-- Created by IntelliJ IDEA. User: Wangcc Date: 2017/10/14 Time: 20:04 To change this template use File | Settings | File Templates.--%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title></head><body>helloJsp<hr>${hello}</body></html>
阅读全文
0 0
- Spring boot 添加jsp模版支持
- Spring Boot 添加JSP支持
- Spring Boot 添加JSP支持
- Spring boot 添加jsp支持配置
- Spring Boot 学习10--添加JSP支持
- Spring boot添加对jsp的支持
- 19. Spring Boot 添加JSP支持【从零开始学Spring Boot】
- 19. Spring Boot 添加JSP支持【从零开始学Spring Boot】
- 19. Spring Boot 添加JSP支持【从零开始学Spring Boot】
- Spring Boot 添加JSP支持【从零开始学Spring Boot】
- (19)Spring Boot 添加JSP支持【从零开始学Spring Boot】
- Spring Boot 添加 Thymeleaf 支持
- Spring Boot 添加Shiro支持
- Spring Boot添加JSP模板
- spring boot 支持jar包运行jsp
- spring boot 支持jar包运行jsp
- Spring Boot学习之旅:(十一)模版引擎-jsp
- spring-boot 添加跨域支持
- 链表倒置
- Basic Data Structure(HDU 5929 2016东北地区CCPC)
- spring01
- 如何更改Android studio中SDK,AVD的默认路径
- 管理输入输出与vim使用
- Spring boot 添加jsp模版支持
- 二进制全加器(只涉及一位加法)逻辑图和电路图
- java中的继承与多态总结
- HDU 5193 Go to movies Ⅱ 块状链表套树状数组(带插入和删除的逆序对)
- 5.查找命令(find)
- The JRE could not be found. Edit the server and change the JRE location.
- Golang设计模式之装饰模式
- Linux —— Vim查找替换
- 杭电acm刷题记录ID1002