Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS与SpringMVC和JBossAS的链接_Css_Spring Mvc_Model View Controller_Jboss - Fatal编程技术网

CSS与SpringMVC和JBossAS的链接

CSS与SpringMVC和JBossAS的链接,css,spring-mvc,model-view-controller,jboss,Css,Spring Mvc,Model View Controller,Jboss,我将SpringMVC与JBoss一起作为7.1.1最终版本使用 我的项目组织如下: Web Pages |-- WEB-INF | |--jsp | | |-- index.jsp | |-- applicationContext.xml | |-- dispatcher-servlet.xml | |-- jboss-web.xml | |-- web.xml |-- resources | |-- css | |-- layout.css |--

我将SpringMVC与JBoss一起作为7.1.1最终版本使用

我的项目组织如下:

Web Pages
|-- WEB-INF
|   |--jsp
|   |  |-- index.jsp
|   |-- applicationContext.xml
|   |-- dispatcher-servlet.xml
|   |-- jboss-web.xml
|   |-- web.xml
|-- resources
|   |-- css
|       |-- layout.css
|-- redirect.jsp
文件web.xml是:

<?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" 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_3_0.xsd">
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <servlet>
            <servlet-name>dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>2</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>redirect.jsp</welcome-file>
        </welcome-file-list>
    </web-app>
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <context-root>/GUI</context-root>
</jboss-web>

上下文配置位置
/WEB-INF/applicationContext.xml
org.springframework.web.context.ContextLoaderListener
调度员
org.springframework.web.servlet.DispatcherServlet
2.
调度员
/
30
redirect.jsp
jboss-web.xml文件是:

<?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" 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_3_0.xsd">
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <servlet>
            <servlet-name>dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>2</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>redirect.jsp</welcome-file>
        </welcome-file-list>
    </web-app>
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <context-root>/GUI</context-root>
</jboss-web>

/桂
文件redirect.jsp是:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% response.sendRedirect("index.htm"); %>


我如何在index.jsp中设置指向resources/css/layout.css的链接?

也许我误解了你的问题,但是指向
.css
资源的链接非常简单

<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resource/css/layout.css">

或者,您可以通过Spring资源处理程序映射此类静态内容,如前所述。

您不需要将servlet映射到“/mvc/*”,但JBoss as 7.1似乎存在“/”问题(它不允许应用程序覆盖来自Java配置的映射)。Tomcat、Jetty、JBoss EAP 6.2和AS 8对我来说都很好。