2013-03-19 115 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

相关问题