
{"id":3048,"date":"2021-02-05T14:30:22","date_gmt":"2021-02-05T06:30:22","guid":{"rendered":"http:\/\/127.0.0.2\/?p=3048"},"modified":"2021-02-05T14:30:22","modified_gmt":"2021-02-05T06:30:22","slug":"2020java%e5%be%ae%e6%9c%8d%e5%8a%a1%e6%9e%b6%e6%9e%84%e5%85%ad%e4%b9%8bspringboot%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.9713job.com\/?p=3048","title":{"rendered":"2020java\u5fae\u670d\u52a1\u67b6\u6784\u516d\u4e4bspringboot\u6559\u7a0b"},"content":{"rendered":"<h2>2020java\u5fae\u670d\u52a1\u67b6\u6784\u516d\u4e4bspringboot\u6559\u7a0b<\/h2>\n<h3>\u4e00\u3001SpringBoot\u4ecb\u7ecd<\/h3>\n<p>SpringBoot\u662f\u7531pivotal\u56e2\u961f\u7814\u53d1\u7684\uff0cSpringBoot\u4e0d\u662f\u4e00\u95e8\u65b0\u6280\u672f\uff0c\u53ea\u662f\u5c06\u4e4b\u524d\u7684Spring\uff0cSpringMVC\uff0cdata-jpa\u7b49\u5e38\u7528\u7684\u6846\u67b6\u5c01\u88c5\u5230\u4e86\u4e00\u8d77\uff0c\u5e2e\u52a9\u4f60\u9690\u85cf\u8fd9\u4e9b\u6846\u67b6\u7684\u6574\u5408\u7ec6\u8282\uff0c\u5b9e\u73b0\u654f\u6377\u5f00\u53d1\u3002<\/p>\n<p>SpringBoot\u5c31\u662f\u4e00\u4e2a\u5de5\u5177\u96c6\u3002<\/p>\n<p><strong>SpringBoot\u7684\u7279\u70b9\uff1a<\/strong><\/p>\n<p>1.SpringBoot\u9879\u76ee\u4e0d\u9700\u8981\u6a21\u677f\u5316\u7684\u914d\u7f6e<br \/>\n2.SpringBoot\u4e2d\u6574\u5408\u7b2c\u4e09\u65b9\u6846\u67b6\u65f6\uff0c\u53ea\u9700\u8981\u5bfc\u5165\u76f8\u5e94\u7684starter\u4f9d\u8d56\u5305\uff0c\u5c31\u81ea\u52a8\u6574\u5408\u4e86<br \/>\n3.SpringBoot\u9ed8\u8ba4\u53ea\u6709\u4e00\u4e2a.properties\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4e0d\u63a8\u8350\u4f7f\u7528xml\uff0c\u540e\u671f\u4f1a\u91c7\u7528.java\u6587\u4ef6\u53bb\u7f16\u5199\u914d\u7f6e\u4fe1\u606f<br \/>\n4.SpringBoot\u5de5\u7a0b\u5728\u90e8\u7f72\u65f6\uff0c\u91c7\u7528\u7684\u662fjar\u5305\u65b9\u5f0f\uff0c\u5185\u90e8\u81ea\u52a8\u4f9d\u8d56Tomcat\u5bb9\u5668\uff0c\u63d0\u4f9b\u4e86\u591a\u73af\u5883\u7684\u914d\u7f6e<br \/>\n5.\u540e\u671f\u8981\u5b66\u4e60\u7684\u5fae\u670d\u52a1\u6846\u67b6SpringClound\u9700\u8981\u5efa\u7acb\u5728SpringBoot\u7684\u57fa\u7840\u4e0a<!--more--><\/p>\n<h3>\u4e8c\u3001SpringBoot\u5feb\u901f\u5165\u95e8(\u91cd\u70b9)<\/h3>\n<p>2.1 \u5feb\u901f\u521b\u5efa SpringBoot<\/p>\n<p>2.1.1 \u9009\u62e9\u6784\u5efa\u9879\u76ee\u7684\u7c7b\u578b<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/05\/1.png\" alt=\"\" width=\"680\" \/><br \/>\n2.1.2 \u9879\u76ee\u7684\u63cf\u8ff0<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/05\/2.png\" alt=\"\" width=\"680\" \/><br \/>\n2.1.3 \u6307\u5b9aSpringBoot\u7248\u672c\u548c\u9700\u8981\u7684\u4f9d\u8d56<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/05\/3.png\" alt=\"\" width=\"680\" \/><\/p>\n<p>2.1.4 \u5bfc\u5165\u4f9d\u8d56<\/p>\n<pre>&lt;dependency&gt;\r\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;spring-boot-starter&lt;\/artifactId&gt;\/\/\u5728starter\u540e\u9762\u8ffd\u52a0 -web\r\n&lt;\/dependency&gt;<\/pre>\n<p>2.1.5 \u7f16\u5199Controller<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/05\/4.png\" alt=\"\" width=\"680\" \/><\/p>\n<p>2.1.6 \u6d4b\u8bd5<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/05\/5.png\" alt=\"\" width=\"680\" \/><br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/05\/6.png\" alt=\"\" width=\"680\" \/><\/p>\n<p><strong>2.2\u00a0 SpringBoot\u7684\u76ee\u5f55\u7ed3\u6784<\/strong><\/p>\n<p>2.2.1 pom.xml \u6587\u4ef6<\/p>\n<p>1.\u6307\u5b9a\u4e86\u4e00\u4e2a\u7236\u5de5\u7a0b\uff1a\u6307\u5b9a\u5f53\u524d\u5de5\u7a0b\u4e3aSpringBoot\uff0c\u5e2e\u52a9\u6211\u4eec\u58f0\u660e\u4e86starter\u4f9d\u8d56\u7684\u7248\u672c<br \/>\n2.\u9879\u76ee\u7684\u5143\u6570\u636e\uff1a\u5305\u540d\uff0c\u9879\u76ee\u540d\uff0c\u7248\u672c\u53f7<br \/>\n3.\u6307\u5b9a\u4e86 properties \u4fe1\u606f\uff1a\u6307\u5b9a\u4e86java\u7684\u7248\u672c\u4e3a1.8<br \/>\n4.\u5bfc\u5165\u4f9d\u8d56\uff1a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5bfc\u5165spring-boot-starter\uff0cspring-boot-starter-test<br \/>\n5.\u63d2\u4ef6\uff1aspring-boot-maven-plugin<\/p>\n<p>2.2.2 .gitignore \u6587\u4ef6<\/p>\n<p>\u9ed8\u8ba4\u5e2e\u6211\u4eec\u5ffd\u7565\u4e86\u4e00\u4e9b\u6587\u4ef6\u548c\u76ee\u5f55\uff0c\u907f\u514d\u63d0\u4ea4\u5230git\u4ed3\u5e93\u4e2d<\/p>\n<p>2.2.3 src\u76ee\u5f55<\/p>\n<pre>-src\r\n  -main\r\n    -java\r\n     -\u5305\u540d\r\n      \u542f\u52a8\u7c7b.java # \u9700\u8981\u5c06controller\u7c7b\uff0c\u653e\u5728\u542f\u52a8\u7c7b\u7684\u5b50\u5305\u4e2d\u6216\u8005\u540c\u7ea7\u5305\u4e0b\r\n    -resources\r\n     -static    #\u5b58\u653e\u9759\u6001\u8d44\u6e90\r\n     -templates  #\u5b58\u653e\u6a21\u677f\u9875\u9762\u7684\r\n     application.properties #SpringBoot\u63d0\u4f9b\u7684\u552f\u4e00\u7684\u914d\u7f6e\u6587\u4ef6\r\n  -test   # \u6d4b\u8bd5\r\n<\/pre>\n<p><strong>2.3 SpringBoot\u542f\u52a8\u65b9\u5f0f<\/strong><\/p>\n<p>2.3.1 \u8fd0\u884c\u542f\u52a8\u7c7b\u7684main\u65b9\u6cd5<\/p>\n<p>2.3.2 maven\u6307\u4ee4\uff1amvn spring-boot:run<\/p>\n<p>2.3.3 \u91c7\u7528jar\u5305\u7684\u65b9\u5f0f\u8fd0\u884c<\/p>\n<p>\u5c06\u5f53\u524d\u9879\u76ee\u6253\u5305\u6210\u4e00\u4e2ajar\u5305\uff0c\u5e76\u901a\u8fc7 java -jar jar\u6587\u4ef6<\/p>\n<h3>\u4e09\u3001SpringBoot\u5e38\u7528\u6ce8\u89e3(\u91cd\u70b9)<\/h3>\n<p>3.1 @Configuration\u548c @Bean<\/p>\n<p>\u4e4b\u524d\u4f7f\u7528SSM\u5f00\u53d1\u65f6\uff0c\u5728xml\u6587\u4ef6\u4e2d\u7f16\u5199bean\u6807\u7b7e\uff0c\u4f46\u662fspringboot\u4e0d\u63a8\u8350\u4f7f\u7528xml<br \/>\n@Configuration\u6ce8\u89e3\u76f8\u5f53\u4e8ebeans\u6807\u7b7e<br \/>\n@Bean \u76f8\u5f53\u4e8ebean\u6807\u7b7e<br \/>\nid=&#8221;\u65b9\u6cd5\u540d&#8221; | \u6ce8\u89e3\u4e2d\u7684name\u5c5e\u6027(\u4f18\u5148\u7ea7\u66f4\u9ad8)<br \/>\nclass=&#8221;\u65b9\u6cd5\u7684\u8fd4\u56de\u7ed3\u679c&#8221;<\/p>\n<pre>@Configuration  \/\/\u4ee3\u8868\u5f53\u524d\u7c7b\u662f\u4e00\u4e2a\u914d\u7f6e\u7c7b\r\npublic class UserConfig {\r\n    @Bean       \/\/ \u6784\u5efa\u4e00\u4e2a\u5b9e\u4f8b\uff0c\u653e\u5230spring\u5bb9\u5668 \r\n    public User user(){\r\n        return new User(1,\"admin\");\r\n    }\r\n}<\/pre>\n<p><strong>3.2 @SpringBootConfiguration<\/strong><\/p>\n<p>@SpringBootConfiguration \u5c31\u662f\u4e00\u4e2a\u7ec4\u5408\u6ce8\u89e3\uff1a<\/p>\n<p>@SpringBootConfiguration \u5c31\u662f @Configuration\u6ce8\u89e3\uff0c\u4ee3\u8868\u542f\u52a8\u7c7b\u5c31\u662f\u4e00\u4e2a\u914d\u7f6e\u7c7b<\/p>\n<p>@EnableAutoConfiguration \u5e2e\u4f60\u5b9e\u73b0\u81ea\u52a8\u88c5\u914d\uff0cSpringBoot\u5de5\u5382\u542f\u52a8\u65f6\uff0c\u8fd0\u884c\u4e00\u4e2aSpringFactoriesLoader\u7684\u7c7b\uff0c\u52a0\u8f7dMETA-INF\/spring.factories\u914d\u7f6e\u7c7b(\u5df2\u7ecf\u5f00\u542f\u7684)\uff0c\u901a\u8fc7SpringFactoriesLoader\u4e2d\u7684load\u65b9\u6cd5\uff0c\u4ee5for\u5faa\u73af\u7684\u65b9\u5f0f\uff0c\u4e00\u4e2a\u4e00\u4e2a\u52a0\u8f7d\u3002<\/p>\n<p>\u597d\u5904\uff1a\u65e0\u9700\u7f16\u5199\u5927\u91cf\u7684\u6574\u5408\u914d\u7f6e\u4fe1\u606f\uff0c\u53ea\u9700\u8981\u6309\u7167springboot\u63d0\u4f9b\u597d\u7684\u7ea6\u5b9a\u53bb\u6574\u5408\u5373\u53ef<\/p>\n<p>\u574f\u5904\uff1a\u5982\u679c\u8bf4\u4f60\u5bfc\u5165\u4e86\u4e00\u4e2astarter\u4f9d\u8d56\uff0c\u90a3\u4e48\u4f60\u5c31\u9700\u8981\u586b\u5199\u5fc5\u8981\u7684\u914d\u7f6e\u4fe1\u606f<\/p>\n<p>\u624b\u52a8\u5173\u95ed\u81ea\u52a8\u88c5\u914d\u6307\u5b9a\u5185\u5bb9\uff1a@SpringBootApplication(exclude = QuartzAutoConfiguration.class)<\/p>\n<p>@ComponentScan \u76f8\u5f53\u4e8e&lt;context:compent-scan basePackage=&#8221;\u5305\u540d&#8221; \/&gt;\u5e2e\u52a9\u6ce8\u89e3\u626b\u63cf\u7684<\/p>\n<h3>\u56db\u3001SpringBoot\u5e38\u7528\u914d\u7f6e(\u91cd\u70b9)<\/h3>\n<p><strong>4.1 SpringBoot\u7684\u914d\u7f6e\u6587\u4ef6\u683c\u5f0f<\/strong><\/p>\n<p>SpringBoot\u7684\u914d\u7f6e\u6587\u4ef6\u652f\u6301 properties \u548c yml \uff0c\u751a\u81f3\u8fd8\u652f\u6301json<\/p>\n<p>\u66f4\u63a8\u8350\u4f7f\u7528 yml\u6587\u4ef6\u683c\u5f0f\uff1a<\/p>\n<p>1.yml\u6587\u4ef6\u4f1a\u6839\u636e\u6362\u884c\u548c\u7f29\u8fdb\u5e2e\u52a9\u6211\u4eec\u7ba1\u7406\u914d\u7f6e\u6587\u4ef6\u6240\u5728\u4f4d\u7f6e<br \/>\n2. yml \u6587\u4ef6\uff0c\u76f8\u6bd4properties\u66f4\u8f7b\u91cf\u7ea7\u4e00\u4e9b<\/p>\n<p>yml\u7684\u52a3\u52bf\uff1a<\/p>\n<p>1.\u4e25\u683c\u9075\u5b88\u6362\u884c\u548c\u7f29\u8fdb<br \/>\n2.\u5728\u586b\u5199value\u65f6\uff0c\u4e00\u5b9a\u8981\u5728:\u540e\u9762\u8ddf\u4e0a\u7a7a\u683c<\/p>\n<p><strong>4.2 \u591a\u73af\u5883\u914d\u7f6e<\/strong><\/p>\n<p>\u5728application.yml \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u914d\u7f6e\u9879\uff1a<\/p>\n<pre>spring:\r\n  profiles:\r\n    active: \u73af\u5883\u540d<\/pre>\n<p>\u5728 resources\u76ee\u5f55\u4e0b\u521b\u5efa\u591a\u4e2a application-\u73af\u5883\u540d.yml \u6587\u4ef6\u5373\u53ef\uff0c\u5728\u90e8\u7f72\u5de5\u7a0b\u65f6\uff0c<br \/>\n\u901a\u8fc7 java -jar jar\u6587\u4ef6 &#8211;spring.properties.active=\u73af\u5883<\/p>\n<p><strong>4.3 \u5f15\u5165\u5916\u90e8\u914d\u7f6e\u6587\u4ef6\u4fe1\u606f<\/strong><\/p>\n<p>\u548c\u4f20\u7edf\u7684SSM\u65b9\u5f0f\u4e0d\u4e00\u6837\uff0c\u901a\u8fc7 @Value\u7684\u6ce8\u89e3\u53bb\u83b7\u53d6properties\/yml\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u3002<br \/>\n\u5982\u679c\u5728yml\u6587\u4ef6\u4e2d\u9700\u8981\u7f16\u5199\u5927\u91cf\u7684\u81ea\u5b9a\u4e49\u914d\u7f6e\uff0c\u5e76\u4e14\u5177\u6709\u7edf\u4e00\u7684\u524d\u7f00\u65f6\uff0c\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f<\/p>\n<pre>@ConfigurationProperties(prefix = \"aliyun\")\r\n@Component\r\n@Data\r\npublic class AliyunProperties {\r\n    private String aaaa;\r\n    private String bbbb;\r\n}<\/pre>\n<p>yml\u914d\u7f6e\u6587\u4ef6<\/p>\n<pre>aliyun:\r\n  aaaa: aaaaa\r\n  bbbb: bbbbb<\/pre>\n<p><strong>4.4 \u70ed\u52a0\u8f7d<\/strong><\/p>\n<p>4.4.1 \u5bfc\u5165\u4f9d\u8d56<\/p>\n<pre>&lt;dependency&gt;\r\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;spring-boot-devtools&lt;\/artifactId&gt;\r\n    &lt;optional&gt;true&lt;\/optional&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>4.4.2 settings\u914d\u7f6e<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/05\/8.png\" alt=\"\" width=\"680\" \/><br \/>\n4.4.3 \u91cd\u65b0\u6784\u5efa\u5de5\u7a0b<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/05\/9.png\" alt=\"\" width=\"680\" \/><\/p>\n<h3>\u4e94\u3001SpringBoot\u6574\u5408Mybatis(\u91cd\u70b9)<\/h3>\n<p><strong>5.1 xml\u65b9\u5f0f\u6574\u5408mybatis<\/strong><\/p>\n<p>xml\u65b9\u5f0f\u5728\u7f16\u5199\u590d\u6742SQL\u65f6\uff0c\u66f4\u9002\u5408<\/p>\n<p>5.1.1 \u5bfc\u5165\u4f9d\u8d56<\/p>\n<pre>&lt;!-- mysql\u9a71\u52a8 --&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;mysql&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;mysql-connector-java&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;\r\n&lt;!-- druid\u8fde\u63a5 --&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;com.alibaba&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;druid-spring-boot-starter&lt;\/artifactId&gt;\r\n    &lt;version&gt;1.1.10&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;!-- mybatis--&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;org.mybatis.spring.boot&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;mybatis-spring-boot-starter&lt;\/artifactId&gt;\r\n    &lt;version&gt;1.3.2&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>5.1.2 \u7f16\u5199\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>1.\u51c6\u5907\u5b9e\u4f53\u7c7b \u5e76\u5b9e\u73b0Serializable\u63a5\u53e3<br \/>\n2.\u51c6\u5907mybatis\u9006\u5411\u5de5\u7a0b<br \/>\n3.yml\u6587\u4ef6<\/p>\n<pre>mybatis:\r\n  # \u626b\u63cf\u6620\u5c04\u6587\u4ef6\r\n  mapper-locations: classpath:mapper\/*.xml\r\n  # \u914d\u7f6e\u522b\u540d\u626b\u63cf\u7684\u5305\r\n  type-aliases-package: com.evshou.admin.firstspringboot.entity\r\n  configuration:\r\n    # \u5f00\u542f\u9a7c\u5cf0\u6620\u5c04\u914d\u7f6e\r\n    map-underscore-to-camel-case: true\r\nspring:\r\n  datasource:\r\n    driver-class-name: com.mysql.cj.jdbc.Driver\r\n    url: jdbc:mysql:\/\/\/\u5e93\u540d?serverTimezone=UTC\r\n    username: root\r\n    password: root\r\n    type: com.alibaba.druid.pool.DruidDataSource<\/pre>\n<p>5.1.4 \u6d4b\u8bd5<\/p>\n<p><strong>5.2 \u6ce8\u89e3\u65b9\u5f0f\u6574\u5408mybatis<\/strong><\/p>\n<p>\u6ce8\u89e3\u65b9\u5f0f\u5728\u7f16\u5199\u914d\u7f6e\u7b80\u5355\uff0c\u7b80\u5355sql\u63a8\u8350\u4f7f\u7528<\/p>\n<p>5.2.1 \u521b\u5efa \u5b9e\u4f53\u7c7b\u7684 mapper\u63a5\u53e3<\/p>\n<p>5.2.2 \u6dfb\u52a0mybatis\u6ce8\u89e3<\/p>\n<p>\u9488\u5bf9\u589e\u5220\u6539\u67e5\uff1a@Insert,@Delete,@Update,@Selete<br \/>\n\u8fd8\u662f\u9700\u8981\u5728\u542f\u52a8\u7c7b\u4e2d\u6dfb\u52a0 @MapperScan \u6ce8\u89e3<\/p>\n<p>@Select(&#8220;select*from user&#8221;)<br \/>\nList&lt;User&gt; queryAllUser();<\/p>\n<p>5.2.3 \u6dfb\u52a0\u914d\u7f6e<\/p>\n<pre>logging:\r\n  level:\r\n    com.evshou.admin.firstspringboot.mapper: DEBUG<\/pre>\n<p>5.2.4 \u6d4b\u8bd5\uff0c\u67e5\u770b\u65e5\u5fd7<\/p>\n<p>\u521b\u5efa\u6d4b\u8bd5\u7c7b\u5e76\u7ee7\u627fFirstSpringBootApplicationTests\uff0c\u81ea\u52a8\u88c5\u914dmapper\u5bf9\u8c61<\/p>\n<p><strong>5.3 SpringBoot\u6574\u5408\u5206\u9875\u52a9\u624b<\/strong><\/p>\n<p>5.3.1 \u5bfc\u5165\u4f9d\u8d56<\/p>\n<pre>&lt;!-- \u5206\u9875 --&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;com.github.pagehelper&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;pagehelper-spring-boot-starter&lt;\/artifactId&gt;\r\n    &lt;version&gt;1.2.5&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>5.3.2 \u6d4b\u8bd5<br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/05\/10.png\" alt=\"\" width=\"680\" \/><\/p>\n<h3>\u516d\u3001SpringBoot\u6574\u5408JSP<\/h3>\n<p>6.1 \u5bfc\u5165\u4f9d\u8d56<\/p>\n<pre>&lt;!-- jsp\u6838\u5fc3\u5f15\u64ce\u4f9d\u8d56--&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;org.apache.tomcat.embed&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;tomcat-embed-jasper&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;\r\n&lt;!-- JSTL --&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;javax.servlet&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;jstl&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>6.2 \u521b\u5efa jsp\u9875\u9762<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/05\/11.png\" alt=\"\" width=\"680\" \/><\/p>\n<p>6.3 \u914d\u7f6e\u524d\u7f00\u548c\u540e\u7f00<\/p>\n<pre>spring:\r\n  mvc:\r\n    view:\r\n      prefix: \/WEB-INF\/\r\n      suffix: .jsp<\/pre>\n<p>6.4 \u521b\u5efa controller<\/p>\n<pre>@Controller\r\npublic class JspController {\r\n    @GetMapping(\"\/index\")\r\n    public String index(Model model){\r\n        model.addAttribute(\"username\",\"\u5f20\u4e09\");\r\n        return \"index\";\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2020java\u5fae\u670d\u52a1\u67b6\u6784\u516d\u4e4bspringboot\u6559\u7a0b \u4e00\u3001SpringBoot\u4ecb\u7ecd SpringBoot\u662f\u7531 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-3048","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/3048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3048"}],"version-history":[{"count":2,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/3048\/revisions"}],"predecessor-version":[{"id":3050,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/3048\/revisions\/3050"}],"wp:attachment":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}