2017-03-09 112 views
0

嗨,我有一個問題,試圖將我的Maven jsp college項目部署到bluemix服務器。每件事都在我的Tomcat服務器上本地處理。我使用雲代工來推送服務器,這是好的。索引頁面工作正常,但我無法訪問我得到的網頁例如。未找到Maven Web應用程序部署文件

Error 404: java.io.FileNotFoundException: SRVE0190E: File not found: /handler 

這是一個Java類,它使用註釋來代替在web xml中設置路由,如下所示。

@WebServlet("/handler") 

我的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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>ie.cit.ooss</groupId> 
    <artifactId>BarSurvey</artifactId> 
    <packaging>war</packaging> 
    <version>1.0</version> 
    <name>assignment2 Maven Webapp</name> 
    <url>http://maven.apache.org</url> 
    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>javax.servlet-api</artifactId> 
      <version>3.0.1</version> 
      <scope>provided</scope> 
     </dependency> 
    </dependencies> 
    <build> 
     <finalName>BarSurvey</finalName> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>3.0.0</version> 
       <configuration> 
        <warSourceDirectory>src</warSourceDirectory> 
        <failOnMissingWebXml>false</failOnMissingWebXml> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
    <properties> 
     <maven.compiler.source>1.8</maven.compiler.source> 
     <maven.compiler.target>1.8</maven.compiler.target> 
    </properties> 
</project> 

而我的項目結構看起來像這樣。

enter image description here

你可以在這裏看到我的項目。

https://github.com/yawlhead91/ChocolateBarsSurvey/tree/master/BarSurvey

如果任何人有一定的幫助將是巨大的。

感謝

回答

0

檢查你的web.xml - 您目前正在使用:

<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"> 

當你應該使用:

<web-app 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" 
    version="3.0"> 

看到這個職位:servlet 3.0 @WebServlet use..what will be in web.xml?

+0

嘿感謝您的幫助把你的應用程序。仍然沒有工作壽。 –

1

我克隆你的git項目後做了一些修改:

  1. 的index.jsp文件

    變化<form action="/BarSurvey/handler" method="POST">

    <form action="/handler" method="POST">

  2. Handler.java文件

    變化response.sendRedirect("/BarSurvey/results.jsp");

    to`response.sendRedirect(「/ results.jsp」);

  3. in results。JSP文件

    變化<a href="/BarSurvey">Return</a>

    <a href="/">Return</a>

使用java_buildpack

cf push appname -p target/BarSurvey.war -b java_buildpack