启动器
@SpringBootApplication
public class ApplicationRun {
public static void main(String[] args) {
SpringApplication.run(ApplicationRun.class, args);
}
}
配置类
@Configuration
@EnableWebMvc
public class MyMvcConfig extends WebMvcConfigurerAdapter {
@Bean
public ViewResolver getViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
return resolver;
}
@Override
public void configureDefaultServletHandling(
DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
或者采用配置文件的方式也是可以的
application.yml
注意~ 在 : 后面一定要加上空格!
spring:
mvc:
view:
prefix : /WEB-INF/views/
suffix : .jsp
server:
port: 9999
前端控制器
@Controller
public class SseController {
@RequestMapping(value="/view")
public String get() {
return "see";
}
}