Jboss 7.0.1 服务器,spring MVC,404 未找到问题

发布于 2024-12-21 04:22:00 字数 4765 浏览 2 评论 0原文

我的 web.xml 看起来像这样,

<web-app version="2.5"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <listener>
        <listener-class>com.myapp.mg.listener.TokenListener</listener-class>
    </listener>


    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:applicationContext.xml,
            classpath:applicationContext-DataSource.xml,
            classpath:wurfl-default-ctx.xml,
            classpath:applicationContext-security.xml
        </param-value>
    </context-param>

    <servlet>
        <servlet-name>springwebapp</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:applicationContext-Web.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
</web-app>

我的 applicationContext-Web.xml 文件看起来像这样,

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:device="http://www.springframework.org/schema/mobile/device"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/mvc
                                            http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
                                            http://www.springframework.org/schema/beans
                                            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
                                            http://www.springframework.org/schema/context 
                                            http://www.springframework.org/schema/context/spring-context-3.0.xsd
                                            http://www.springframework.org/schema/mobile/device
                                            http://www.springframework.org/schema/mobile/device/spring-mobile-device-1.0.xsd">

    <!-- FOR MVC RESOURCE MAPPING DEFINITIONS -->

    <mvc:annotation-driven>
        <mvc:argument-resolvers>
            <bean class="org.springframework.mobile.device.DeviceWebArgumentResolver"/>
        </mvc:argument-resolvers>
    </mvc:annotation-driven>
    <context:annotation-config/>

    <mvc:interceptors>
        <bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor">
            <constructor-arg>
                <!-- Inject a WurflDeviceResolver that populates its device repository from the specified file locations -->
                <device:wurfl-device-resolver root-location="classpath:wurfl/wurfl-latest.xml"
                                              patch-locations="classpath:/wurfl/web_browsers_patch.xml"/>
            </constructor-arg>
        </bean>
    </mvc:interceptors>

    <context:component-scan base-package="com.myweb.mg.web"/>



    <bean class="com.myweb.mg.resolver.ExternalResourceViewResolver">
        <property name="viewClass" value="com.myweb.mg.resolver.ExternalResourceView"/>
        <property name="prefix" value="${mg.appHostingFolder}"/>
        <property name="order" value="0"/>
    </bean>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
        <property name="order" value="1"/>
    </bean>

    <bean name="themeResolver" class="org.springframework.web.servlet.theme.FixedThemeResolver">
        <property name="defaultThemeName" value="theme"/>
    </bean>


</beans>

现在,当我在服务器上运行我的应用程序时,它显示 404 错误,即,

type Status report

message /myweb/

description The requested resource (/myweb/) is not available.

任何人都可以在这里为我提供一些指示,因为我是什么这里做错了???

My web.xml looks like this,

<web-app version="2.5"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <listener>
        <listener-class>com.myapp.mg.listener.TokenListener</listener-class>
    </listener>


    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:applicationContext.xml,
            classpath:applicationContext-DataSource.xml,
            classpath:wurfl-default-ctx.xml,
            classpath:applicationContext-security.xml
        </param-value>
    </context-param>

    <servlet>
        <servlet-name>springwebapp</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:applicationContext-Web.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
</web-app>

My applicationContext-Web.xml file looks like this,

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:device="http://www.springframework.org/schema/mobile/device"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/mvc
                                            http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
                                            http://www.springframework.org/schema/beans
                                            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
                                            http://www.springframework.org/schema/context 
                                            http://www.springframework.org/schema/context/spring-context-3.0.xsd
                                            http://www.springframework.org/schema/mobile/device
                                            http://www.springframework.org/schema/mobile/device/spring-mobile-device-1.0.xsd">

    <!-- FOR MVC RESOURCE MAPPING DEFINITIONS -->

    <mvc:annotation-driven>
        <mvc:argument-resolvers>
            <bean class="org.springframework.mobile.device.DeviceWebArgumentResolver"/>
        </mvc:argument-resolvers>
    </mvc:annotation-driven>
    <context:annotation-config/>

    <mvc:interceptors>
        <bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor">
            <constructor-arg>
                <!-- Inject a WurflDeviceResolver that populates its device repository from the specified file locations -->
                <device:wurfl-device-resolver root-location="classpath:wurfl/wurfl-latest.xml"
                                              patch-locations="classpath:/wurfl/web_browsers_patch.xml"/>
            </constructor-arg>
        </bean>
    </mvc:interceptors>

    <context:component-scan base-package="com.myweb.mg.web"/>



    <bean class="com.myweb.mg.resolver.ExternalResourceViewResolver">
        <property name="viewClass" value="com.myweb.mg.resolver.ExternalResourceView"/>
        <property name="prefix" value="${mg.appHostingFolder}"/>
        <property name="order" value="0"/>
    </bean>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
        <property name="order" value="1"/>
    </bean>

    <bean name="themeResolver" class="org.springframework.web.servlet.theme.FixedThemeResolver">
        <property name="defaultThemeName" value="theme"/>
    </bean>


</beans>

Now when I run my application on server it shows me a 404 error, which is,

type Status report

message /myweb/

description The requested resource (/myweb/) is not available.

Can any one please provide me some pointers here as what am I doing wrong here???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文