2013-12-08 50 views
1

我已經創建和Tomcat 7.本web應用程序也有一個RESTful Web服務行家web應用程序,但我不相信這是做一些事情,因爲它的實際工作是錯誤的。 要告訴你什麼,我得到了現在:的Tomcat Web應用程序無法正常工作

這是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>angular-js</groupId> 
    <artifactId>angular-js</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 

    <properties> 
     <java-version>1.7</java-version> 
    </properties> 

    <repositories> 
     <repository> 
      <id>org.jboss.resteasy</id> 
      <url>http://repository.jboss.org/maven2/</url> 
     </repository> 
     <repository> 
      <id>jboss</id> 
      <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url> 
     </repository> 
    </repositories> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <configuration> 
        <webXml>src\main\webapp\WEB-INF\lib\web.xml</webXml> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencies> 
     <dependency> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-resources-plugin</artifactId> 
      <version>2.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.10</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.1.1</version> 
     </dependency> 

     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
     </dependency> 

     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>resteasy-jaxrs</artifactId> 
      <version>2.3.6.Final</version> 
     </dependency> 
     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>resteasy-jackson-provider</artifactId> 
      <version>2.3.6.Final</version> 
     </dependency> 
     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>resteasy-jettison-provider</artifactId> 
      <version>2.3.6.Final</version> 
     </dependency> 
     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>resteasy-multipart-provider</artifactId> 
      <version>2.3.6.Final</version> 
     </dependency> 
     <dependency> 
      <groupId>net.sf.scannotation</groupId> 
      <artifactId>scannotation</artifactId> 
      <version>1.0.2</version> 
     </dependency> 
     <dependency> 
      <groupId>javassist</groupId> 
      <artifactId>javassist</artifactId> 
      <version>3.12.1.GA</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jettison</groupId> 
      <artifactId>jettison</artifactId> 
      <version>1.3.4</version> 
     </dependency> 

     <dependency> 
      <groupId>javax.ws.rs</groupId> 
      <artifactId>jsr311-api</artifactId> 
      <version>0.11</version> 
     </dependency> 
    </dependencies> 

</project> 

這是我的web.xml

<?xml version="1.0" encoding="ISO-8859-1" ?> 

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

    <display-name>AngularJS Application</display-name> 
    <description> 
     This is a simple web application with a source code organization 
     based on the recommendations of the Application Developer's Guide. 
    </description> 

    <welcome-file-list> 
     <welcome-file>index.htm</welcome-file> 
    </welcome-file-list> 

    <listener> 
     <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> 
    </listener> 

    <servlet> 
     <servlet-name>Resteasy</servlet-name> 
     <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>Resteasy</servlet-name> 
     <url-pattern>/*</url-pattern> 
    </servlet-mapping> 

    <context-param> 
     <param-name>resteasy.scan</param-name> 
     <param-value>true</param-value> 
    </context-param> 

    <context-param> 
     <param-name>resteasy.servlet.mapping.prefix</param-name> 
     <param-value>/</param-value> 
    </context-param> 

</web-app>  

這是我的項目結構:

http://puu.sh/5FJGZ.png enter image description here

我相信這一切都還好,但由於某些原因,當我去http://localhost:8080/angular-jshttp://localhost:8080/angular-js/index.htm我從Tomcat的404錯誤,資源沒有找到。

你知道這裏是哪裏呢? :S一直在這工作幾個小時!!!!越來越絕望。

在此先感謝!

+2

你的web.xml文件是錯誤的地點。它應該在WEB-INF文件夾中,而不是lib –

+0

,因爲@JorgeCampos表示web.xml缺失。它應該在WEB-INF文件夾和index.html應在WebApp文件夾 – shakthydoss

+1

@mikeyaworski:請使用'< - 語言:FOO - >'在正文而不是編輯的標籤是在情況下的語法不太相關從問題標籤推斷出的高亮顯示是錯誤的。我回滾了你的編輯,現在添加了內聯語法高亮提示。 – laalto

回答

1

變更位置的web.xml文件,因爲你的項目結構

web.xml文件是在所有的罐子內lib文件夾中,但Eclipse中創建這一個在WEB-INF直接

+0

它的工作!謝謝!!! :')我知道web.xml進入WEB-INF文件夾,而不是lib,但我試圖把它放在那裏,因爲在教程視頻中,設置webapp原型之後,eclipse自動將lib.xml文件添加到lib文件夾中,奇怪的。但無論如何,如果您將pom.xml中的配置修改爲WEB-INF/lib,它將查看lib而不是WEB-INF:P,但是,謝謝,問題在於index.htm的錯位。 – user3078876

相關問題