我正在尝试建立一个框架Spring 3 MVC项目,但我很难获得渲染视图.我遵循了mvc-basic示例项目中描述的结构,并在http://blog.springsource.com/2009/12/21/mvc-simplifications-in-spring-3-0/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Interface21TeamBlog+%28SpringSource+Team+Blog%29处设置了web.xml,app-config.xml和mvc-config.xml文件.控制器被调用,但当它到达查找视图并呈现它时,我得到404错误.文件如下:
web.xml中:
APP-config.xml文件:
MVC-config.xml文件:
在“Java Resources:src”中 – > com.myProject – > HelloWorldController.java我有:
package com.myProject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value="/helloworld")
public class HelloWorldController {
@RequestMapping(method=RequestMethod.GET)
public ModelAndView helloWorld() {
ModelAndView mav = new ModelAndView();
mav.setViewName("helloworld");
mav.addObject("message","Hello World!");
return mav;
}
@RequestMapping(value="/Second",method = RequestMethod.GET)
public ModelAndView Second(){
ModelAndView mav = new ModelAndView();
mav.setViewName("Second");
mav.addObject("message","Hello World!");
return mav;
}
}
在WebContent / WEB-INF / views我有:
WebContent (folder)
WEB-INF (folder)
views (folder)
helloworld (folder)
helloworld.jsp (.jsp view)
helloworld.jsp (.jsp view)
welcome.jsp (.jsp view)
这些观点在其中有直接的html.当我请求http:// localhost:8080 / projectname / app时我正确获取了视图 – > welcome.jsp页面.但是,当我请求http:// localhost:8080 / projectname / app / helloworld或http:// localhost:8080 / projectname / app / helloworld / execution命中正确的控制器操作但我得到HTTP状态404 – / projectname / WEB- INF /视图/的helloWorld.jsp
任何人都可以建议什么是错的?
谢谢