springboot~入门第二篇~页面html跳转~
2021-06-23 09:07
标签:ati templates ide oct ref 截图 port scope ret 遇到的问题:按照别人的blog搭jsp页面就是html页面跳转不了,总是如图: 终于找到了一个能用的blog ,换 thymeleaf(html页面跳转)成功。 控制器代码 注意下: @Controller而不是@RestController,不然也会直接返回字段值 就变成入门(一)写的内容 html代码 application.properties 配置文件 项目文件截图 注意 html的位置被放错 补充:pom.xml写对也是很重要的 最后 http://127.0.0.1:8000/test 访问到(在配置文件中指定了下端口号8000) 于是~愉快得访问到页面啦~~~ 疑问可参考下blog ~~ https://blog.csdn.net/Sicily_winner/article/details/78985187 springboot~入门第二篇~页面html跳转~ 标签:ati templates ide oct ref 截图 port scope ret 原文地址:https://www.cnblogs.com/yizhizhangBlog/p/9671531.htmlimport org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HelloController {
@RequestMapping("/test")
public String test(){
return "login";
}
}
DOCTYPE html>
html lang="en">
head>
meta charset="UTF-8"/>
title>Titletitle>
head>
body>
h1>1314314141h1>
body>
html>
server.port=8000
#spring mvc
spring.thymeleaf.prefix=classpath:/templates/
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.0modelVersion>
groupId>com.how2javagroupId>
artifactId>springbootartifactId>
version>0.0.1-SNAPSHOTversion>
name>springbootname>
description>springbootdescription>
packaging>warpackaging>
parent>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-parentartifactId>
version>1.5.9.RELEASEversion>
parent>
dependencies>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-webartifactId>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-tomcatartifactId>
dependency>
dependency>
groupId>junitgroupId>
artifactId>junitartifactId>
version>3.8.1version>
scope>testscope>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-thymeleafartifactId>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-webartifactId>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-testartifactId>
scope>testscope>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-tomcatartifactId>
scope>providedscope>
dependency>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-devtoolsartifactId>
optional>trueoptional>
dependency>
dependencies>
properties>
java.version>1.8java.version>
properties>
build>
plugins>
plugin>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-maven-pluginartifactId>
plugin>
plugins>
build>
project>
文章标题:springboot~入门第二篇~页面html跳转~
文章链接:http://soscw.com/index.php/essay/97744.html