Spring - PageNotFound:找不到HTTP请求的映射

时间:2013-05-26 22:15:59

标签: spring servlets

我正在尝试添加对正常运行的应用程序的Persual访问权限

以下URL页面没有出现,我收到http 400错误请求。

http://localhost:9080/ASOPartners/perusal.do

使用以下网址获取

PageNotFound  W org.springframework.web.servlet.DispatcherServlet noHandlerFound No mapping found for HTTP request with URI [/ASOPartners/perusal/perusal.do] in DispatcherServlet with name 'asopartners'

http://localhost:9080/ASOPartners/perusal/perusal.do

以下是我的新控制器方法的相关信息

@RequestMapping(value = "/perusal.do")
public String perusal(@RequestHeader(value = USERID_HEADER_KEY, required = false)   String userId,

@RequestHeader(value = COMPANYID_HEADER_KEY, required = false) String companyId,

@RequestHeader(value = "sm_serversessionId", required = false) String sessionId,

@RequestParam(value = USERID_PARAM_KEY, required = true) String appuserID,

@RequestParam(value = "companyId", required = true) String appcompID,

HttpServletRequest servletRequest,

WebRequest webRequest){

initializeUserSession(servletRequest);

这是我在Web.xml中的servlet映射

    <servlet>
    <description>Spring MVC Dispatcher Servlet</description>
    <servlet-name>asopartners</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>asopartners</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>asopartners</servlet-name>
    <url-pattern>/asoclient</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>asopartners</servlet-name>
    <url-pattern>/asocustomer</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>asopartners</servlet-name>
    <url-pattern>/asooperations</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>asopartners</servlet-name>
    <url-pattern>/asooperations/addcompany</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>asopartners</servlet-name>
    <url-pattern>/asocustomer/usermaintenance</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>asopartners</servlet-name>
    <url-pattern>/asooperations/usermaintenance</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>asopartners</servlet-name>
    <url-pattern>/perusal</url-pattern>
</servlet-mapping>

这是我的视图控制器设置

    <!-- YOUR ENTRIES HERE -->
<context:component-scan base-package="com.wellsfargo.asopartners.common.db,
                                      com.wellsfargo.asopartners.factory,
                                      com.wellsfargo.asopartners.web,
                                      com.wellsfargo.asopartners.validator,
                                      com.wellsfargo.asopartners.dao">
</context:component-scan>

<!-- Configures the @Controller programming model -->
<mvc:annotation-driven />

<!-- Forwards requests to the "/" resource to the "welcome" view -->
<mvc:view-controller path="/perusal" view-name="redirect:perusal.do"/>
<mvc:view-controller path="/asocustomer" view-name="redirect:asocustomer/customer.do"/>
<mvc:view-controller path="/asocustomer/usermaintenance" view-name="redirect:usermaintenance/userMaintenance.do"/>
<mvc:view-controller path="/asoclient" view-name="redirect:asoclient/custClient.do"/>
<mvc:view-controller path="/asooperations" view-name="redirect:asooperations/operator.do"/>
<mvc:view-controller path="/asooperations/usermaintenance" view-name="redirect:usermaintenance/userMaintenance.do"/>
<mvc:view-controller path="/asooperations/addcompany" view-name="redirect:addcompany/addCompany.do"/>

我真的很喜欢自己试图解决这个问题。在配置中它必须是非常简单的东西,我正在寻求专家的帮助。谢谢。

1 个答案:

答案 0 :(得分:0)

使用第一个网址:

http://localhost:9080/ASOPartners/perusal.do

问题是您没有将required @RequestParam属性作为带有URL的查询参数传递。它们设置为required = true。因此400 Bad Request

使用第二个网址:

http://localhost:9080/ASOPartners/perusal/perusal.do

配置中的任何位置都没有映射来解析该URL。也就是说,您的控制器方法绑定到/perusal.do,而不是/peruslal/perusal.do