为什么80%的码农都做不了架构师?>>>
1、首先配置pom文件
4.0.0
org.springframework.boot
spring-boot-starter-parent
1.5.2.RELEASE
com.ttt
web
1.0-TTT-SNAPSHOT
war
web-ad
UTF-8
UTF-8
1.8
commons-io
commons-io
2.5
commons-fileupload
commons-fileupload
1.3.2
javax.servlet
jstl
org.apache.tomcat.embed
tomcat-embed-jasper
provided
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-tomcat
provided
web
org.springframework.boot
spring-boot-maven-plugin
org.apache.maven.plugins
maven-war-plugin
false
2、配置文件配置jsp文件路径及页面热加载部署开启(建议生产环境去掉此配置)
spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp
#\u5373\u65F6\u7F16\u8BD1jsp\uFF0C \u751F\u4EA7\u73AF\u5883\u4E0D\u5EFA\u8BAE\u4F7F\u7528\uFF0C\u964D\u4F4E\u6027\u80FD
server.jsp-servlet.init-parameters.development=true
3、在webapp下创建WEB-INF目录,创建getDl.jsp文件存放于该目录下
src/main/webapp/WEB-INF/getDl.jsp
4、启动类配置不变
@SpringBootApplication
public class WebAdApplication {
public static void main(String[] args) {
SpringApplication.run(WebAdApplication.class, args);
}
}
5、Controller跳转页面
@RestController
@RequestMapping(value = "/web")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class AdController extends WebBaseController {
@GetMapping(value = "/getDl")
public ModelAndView getDl() {
return new ModelAndView("getDl", new HashMap("qqq","www"));
}
}
6、至此,配置完毕,切记:此种方式只适合java -jar 命令启动,如果将war包放入Tomcat中启动还是会报错的,至于怎么能将打出的war包放入Tomcat中加载启动,且听下回分解。