查看没有得到解决弹簧启动web

时间:2016-05-27 04:00:49

标签: spring-mvc spring-boot

我是Spring boot web mvc的新手。我对RequestMapping(“/”)的看法没有得到解决。下面我分享了所需的代码 我的控制器类是

@Controller 
public class ExpenseSheetController {

@Autowired
private ExpenseSheetDao expenseSheetDao;

@RequestMapping("/")
public ModelAndView home() {

    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("home");
    modelAndView.addObject("message","on home page");

    return modelAndView;
 }
}

pom.xml如下

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.5.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>


    <!-- my-sql connector -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>

我将 src / main / resources / templates 视为 home.html

0 个答案:

没有答案