2014-03-29 16 views
5

我試圖做一個簡單的春天啓動的Web應用程序:春天啓動的Web起動意見位置

POM:

<parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.0.0.BUILD-SNAPSHOT</version> 
    </parent> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-actuator</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

主要類:

@ComponentScan(basePackages={"controller"}) 
@Import(MvcConfig.class) 
@EnableAutoConfiguration 
public class Application { 

    public static void main(String[] args) { 
     SpringApplication.run(Application.class, args); 
    } 
} 

控制器:

@Controller 
@RequestMapping("/home") 
public class HomeController { 
    @RequestMapping("/hello") 
    @ResponseBody 
    public String hello(){ 
     return "hello"; 
    } 
    @RequestMapping("/helloView") 
    public String helloView(){ 
     return "homeView"; 
    } 
} 

也在src/main我得到

src 
    -main 
     -resources 
      applicaion.properties 
     -webapp 
      -WEB-INF 
       -jsp 
        -homeView.jsp 

在application.properties我:

spring.view.prefix: /WEB-INF/jsp/ 
    spring.view.suffix: .jsp 

其餘端點/home/hello作品,但另一個無法打開JSP。 在日誌中我得到

Looking up handler method for path /WEB-INF/jsp/homeView.jsp 
Did not find handler method for [/WEB-INF/jsp/homeView.jsp] 

我應該在哪裏把這樣的應用程序的意見,可以找到它們?

+2

查看Spring Boot的github存儲庫中的以下示例https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-jsp – geoand

回答

3

由於geoand的回答我說

 <dependency> 
      <groupId>org.apache.tomcat.embed</groupId> 
      <artifactId>tomcat-embed-jasper</artifactId> 
      <scope>provided</scope> 
     </dependency> 

到POM和它的工作。