我正在尝试使用 Spring启动的快速原型.
我有以下控制器代码减去导入
@EnableAutoConfiguration
@RestController
@Controller
public class IndexController{
@RequestMapping(value = "/")
public ModelAndView firstPage(HttpServletRequest request, HttpServletResponse response){
ModelAndView mv = new ModelAndView("index");
mv.addObject("message", Calendar.getInstance().getTime().toString());
return mv;
}
@RequestMapping(value="/gotoNextPage",method = RequestMethod.GET)
public ModelAndView gotoNextPage(HttpServletRequest request, HttpServletResponse response){
System.out.println("Inside gotoNextPage!!!!!!");
ModelAndView mv = new ModelAndView("redirect:nextpage");
mv.addObject("message", "next page");
return mv;
}
}
从我的HTML,我调用/ gotoNextPage,在我的服务器中,我看到里面的gotoNextPage !!!!打印声明.但是,nextPage不会加载.如果我不使用重定向并输入http://localhost:8080/gotoNextPage,则HTML内容加载正常.此外,index.html也加载正常
我正在使用spring boot mvc,thymeleaf,angularjs
我的项目结构如下所示:
enter image description here
我的POM XML文件依赖关系如下所示:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
ng-spring-boot-helloworld
ng-spring-boot-helloworld
1.0.0
org.springframework.boot
spring-boot-starter-parent
1.2.0.RELEASE
org.hsqldb
hsqldb
2.3.2
org.springframework.boot
spring-boot-starter-thymeleaf
1.2.7.RELEASE
org.springframework.boot
spring-boot-maven-plugin
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-starter-thymeleaf
org.hsqldb
hsqldb
runtime
请帮忙.
提前致谢.