可能重复:
Tiles 2 And No mapping found for HTTP request with URI - Spring-MVC
我无法理解我的代码有什么问题。请你帮助我好吗。 代码如下:
springapp-servlet.xml包含:
<mvc:annotation-driven/>
<context:component-scan base-package="controllers"/>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
控制器类:
package controllers;
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;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping(value = "/views")
public class TestController {
@RequestMapping(value = "/index", method = RequestMethod.GET)
public ModelAndView viewEvents() {
Map model = new HashMap();
model.put("result", "TestResult");
return new ModelAndView ("page1", model);
}
}
我想当我打开url localhost:8080 / myapp / views / index.jsp 控制器必须调度此请求并将我重定向到page1,其中变量result将可用。但相反,我在我的jBoss控制台中收到警告并且没有发生:
WARN [org.springframework.web.servlet.PageNotFound] (http--127.0.0.1-8080-1) No mapping found for HTTP request with URI [/jammies-1.0/WEB-INF/views/views/page1.jsp] in DispatcherServlet with name 'myapp'
我的代码和配置文件有什么问题? 在此先感谢)
答案 0 :(得分:0)
正如肯特所说,你在views / views文件夹下有page1.jsp吗?您可能在视图中的page1.jsp不在views / views
中