标签:release enc nbsp spring http ima relative rest localhost
1.创建web工程
2.配置springmvc以及web.xml
3.编写Controller
4.部署tomcat
在没有联网的情况下,依旧可以创建工程,创建一个空工程,自己导入依赖,创建启动类
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.2.RELEASE</version> <relativePath/> </parent>
<dependencies> <!--因为没有tomcat,所以要添加spring mvc的依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
@RestController public class PojoController { @RequestMapping("/hello") public Map sayHello(){ Map map = new HashMap(); map.put("hi","sayhello"); return map; } }
@SpringBootApplication //主启动类 public class HelloApplication { public static void main(String[] args) { //run()方法的参数是本身的字节码和一个参数 SpringApplication.run(HelloApplication.class,args); } }
并访问Controller中的url:http://localhost:8080/hello
标签:release enc nbsp spring http ima relative rest localhost
原文地址:https://www.cnblogs.com/zhy819/p/11807569.html