0

可能重复:
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,其中变量结果将可用。但相反,我在我的 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'

我的代码和配置文件有什么问题?提前致谢)

4

1 回答 1

0

正如肯特所提到的,你在views/views 文件夹下有page1.jsp 吗?您可能在视图中没有 page1.jsp 在视图/视图中

于 2012-10-04T12:21:51.477 回答