2013-03-19 116 views
0

我在添加javascript和css文件到我的maven,spring webapp項目時遇到了一些麻煩。春天的web應用程序添加到HTML文件的Javascript和CSS

我正在搜索網頁和這裏,但有問題把它放在正確的地方。

我想要做什麼,是有根上下文中的index.html頁面,並從它,參考當地的javascript文件系統

的.war佈局

war/ 
    index.html 
    js/ 
    javascript.js 
    css/ 
    default.css 
    WEB-INF/ 
    classes/ 
     *.classes 
    lib/ 
     *.jar 
    springapp-servlet.xml 
    web.xml 

index.html文件

<html> 
<head> 
<link href="css/jquery.mobile-1.3.0.css" rel="stylesheet" type="text/css"> 
<script type="text/javascript" src="js/jquery.mobile-1.3.0.js"></script> 
</head> 
<body> 
    <div data-role="header"> 
    <h1>Page Title</h1> 
    </div> 
</body> 
</html> 

的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" 
    id="WebApp_ID" version="2.5"> 
    <display-name>springTest</display-name> 

    <servlet> 
     <servlet-name>springapp</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>springapp</servlet-name> 
     <url-pattern>*.do</url-pattern> 
    </servlet-mapping> 
</web-app> 

springapp-servlet.xml的

<?xml version="1.0" encoding="UTF-8"?> 
<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-2.5.xsd 
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <!-- View resolvers --> 

    <bean id="viewResolver" 
     class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> 
     <property name="cache" value="false" /> 
     <property name="prefix" value="" /> 
     <property name="suffix" value=".vm" /> 
    </bean> 

    <bean id="velocityConfig" 
     class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> 
    </bean> 

<!-- controllers and java service beans --> 
..... 

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

</beans> 

現在,我認爲這將使可用於在HTML文件鏈接的js和css迪爾斯,但我只是得到一個純文本,不查詢的移動視圖。

使用Spring和Maven在Jboss AS 7中運行它。

問候 亨裏克

+0

你是什麼意思「,但我只是得到一個純文本,不查詢移動觀點「?如果你檢查生成的html,你看到了什麼?任何錯誤(404或其他),你看到導入的文件? – 2013-03-19 21:47:57

+0

這些文件在戰爭中,jquerymobile既css和js ....將盡快檢查控制檯。當然他們是 – Hiny 2013-03-20 11:56:32

+0

,但是firebug或chrome控制檯打印出來是什麼?您是否在瀏覽器下載的文件中看到這些文件? – 2013-03-20 12:15:58

回答

0

嗯,得到它的工作,不知何故,與結構我有....

+0

你是如何得到它的工作的? – rgettman 2013-03-20 18:12:31

+0

那就是事情,我沒有改變任何東西.... 雖然有一些奇怪的JQuery手機,所以我改變他們到在線參考,只是我的本地變化/覆蓋添加... – Hiny 2013-03-20 18:24:09

相關問題