0

您好,我有一个带有 Hibernate 的 Spring MVC 应用程序,但问题是我没有正确配置,因为对于路由,对于库 .js 和 .css 的导入,我必须使用 pageContext.request.contextPath,我展示了我的设置:

• web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
    <display-name>extjs_commerceapp-solution</display-name>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
              /WEB-INF/commerceapp-servlet.xml
          </param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>commerceapp</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>    
    <servlet-mapping>
        <servlet-name>commerceapp</servlet-name>
        <url-pattern>/mvc/*</url-pattern>
    </servlet-mapping>
</web-app>

• commerceapp-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        ">
    <mvc:annotation-driven />
    <context:component-scan base-package="com.limati.commerceapp" />
    <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/jsp/com/limati/commerceapp/" />
        <property name="suffix" value=".jsp" />
    </bean>
    <!-- Configures Hibernate - Database Config -->
    <import resource="commerceapp-dao-hibernate.xml" />
    <import resource="commerceapp-service.xml" />
</beans>

通过 commerceapp-servlet.xml,我导入了另外两个设置 Hibernate XML。问题是我的主页加载了我的 RIA 接口,我必须放置这个路由(pageContext.request.contextPath):

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>CommerceApp</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/ext4/resources/css/ext-all.css"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/ext4/ext-all-debug.js"></script>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/css/app.css"/>
    </head>
    <body style="background-color: #95B0CD" >
        <script type="text/javascript">
            Ext.Loader.setConfig({
                enabled: true,
                paths:{
                    "app": "${pageContext.request.contextPath}/app"
                }
            });  
            var CONTEXT_PATH = "${pageContext.request.contextPath}";
            var USER = "${sessionScope.user.userName}";
            app=Ext.create('Ext.app.Application',{
                name:'LTI',
                appFolder: 'app/base/user',
                //controllers:['UserController'],    //si se quiere inicializar un controlador en la creación
                launch: function(){        
                    Ext.create("app.principal.view.Desktop",{
                    });      
                }        
            });

        </script>
    </body>
</html>

有人可以帮我解决这个问题。

4

1 回答 1

0

我认为您必须添加此标签

<mvc:resources mapping="/resources/**" location="/resources/" />

处理静态资源。意味着将所有静态资源放在资源文件夹中,或者您可以根据需要更改位置。

于 2013-08-28T11:16:11.023 回答