2016-07-14 7 views
0

build.xml、build.properties、およびwar/index.jspファイルを作成します。 web.xmlを含むwar/WEB-INFディレクトリも作成しました。私は、一般的なエラーはディレクトリ構造であることを見てきました。私が正しいことを確認しました。また、パスが正しいことを確認しました。春MVCアプリケーションがブラウザに表示されないindex.jspを、HTTP 404結果

私のビルドファイルはAntで正しくコンパイル、ビルド、デプロイします。しかし、なぜ "> ant list"コマンドが "running"の代わりに "stopped"状態になるのか理解できません。以下の実行を参照してください。

私のブラウザでindex.jspリソースが見つかりませんでしたか?私はこの時点で何をすべきか分かりません。

Springで他にも優れたMVCチュートリアルはありますか?これは最も深く思えました。

Tom:springapp tom$ ant 
Buildfile: /Users/tom/Projects/springapp/build.xml 

usage: 
    [echo] 
    [echo] springapp build file 
    [echo] ----------------------------------- 
    [echo] 
    [echo] Available targets are: 
    [echo] 
    [echo] build  --> Build the application 
    [echo] deploy --> Deploy application as directory 
    [echo] deploywar --> Deploy application as a WAR file 
    [echo] install --> Install application in Tomcat 
    [echo] reload --> Reload application in Tomcat 
    [echo] start  --> Start Tomcat application 
    [echo] stop  --> Stop Tomcat application 
    [echo] list  --> List Tomcat application 
    [echo] 

BUILD SUCCESSFUL 
Total time: 0 seconds 
Tom:springapp tom$ ant build 
Buildfile: /Users/tom/Projects/springapp/build.xml 

build: 

BUILD SUCCESSFUL 
Total time: 0 seconds 
Tom:springapp tom$ ant deploy 
Buildfile: /Users/tom/Projects/springapp/build.xml 

build: 

deploy: 

BUILD SUCCESSFUL 
Total time: 0 seconds 
Tom:springapp tom$ ant list 
Buildfile: /Users/tom/Projects/springapp/build.xml 

list: 
[list] OK - Listed applications for virtual host localhost 
[list] /:running:0:ROOT 
[list] /examples:running:0:examples 
[list] /host-manager:running:0:host-manager 
[list] /springapp:stopped:0:springapp 
[list] /manager:running:0:manager 
[list] /docs:running:0:docs 

BUILD SUCCESSFUL 
Total time: 0 seconds 

私は私のブラウザ経由で私のアプリに到達しようとした場合:

http://localhost:8080 - > Tomcatのランディングページを取得します

"___________________" /マネージャー/ htmlの - >作品OKワット/ログイン

"___________________"/springapp/index.jsp - >結果はHTTP 404

何を行うかわかりません。私はすべてのファイルのタイプミスをチェックしました。 TomcatとJavaの新しいバージョン用に調整されました。ソースファイルは以下の通りです。

のbuild.xml:

<?xml version="1.0"?> 

<project name="springapp" basedir="/Users/tom/Projects/springapp" default="usage"> 
<property file="build.properties"/> 

<property name="src.dir" value="src"/> 
<property name="web.dir" value="war"/> 
<property name="build.dir" value="${web.dir}/WEB-INF/classes"/> 
<property name="name" value="springapp"/> 

<path id="master-classpath"> 
    <fileset dir="${web.dir}/WEB-INF/lib"> 
     <include name="*.jar"/> 
    </fileset> 
    <fileset dir="${appserver.lib}"> 
     <include name="servlet-api.jar"/> 
    </fileset> 
    <pathelement path="{$build.dir}"/> 
</path> 

<target name="usage"> 
    <echo message=""/> 
    <echo message="${name} build file"/> 
    <echo message="-----------------------------------"/> 
    <echo message=""/> 
    <echo message="Available targets are:"/> 
    <echo message=""/> 
    <echo message="build  --> Build the application"/> 
    <echo message="deploy --> Deploy application as directory"/> 
    <echo message="deploywar --> Deploy application as a WAR file"/> 
    <echo message="install --> Install application in Tomcat"/> 
    <echo message="reload --> Reload application in Tomcat"/> 
    <echo message="start  --> Start Tomcat application"/> 
    <echo message="stop  --> Stop Tomcat application"/> 
    <echo message="list  --> List Tomcat application"/> 
    <echo message=""/> 
</target> 

<target name="build" description="Compile main source tree java files"> 
    <mkdir dir="S{build.dir}"/> 
    <javac destdir="${build.dir}" source="1.8.0_60" target="1.8.0_60" debug="true" 
     deprecation="false" optimize="false" failonerror="true" includeantruntime="true"> 
     <src path="${src.dir}"/> 
     <classpath refid="master-classpath"/> 
    </javac> 
</target> 

<target name="deploy" depends="build" description="Deploy application"> 
    <copy todir="${deploy.path}/${name}" preservelastmodified="true"> 
     <fileset dir="${web.dir}"> 
      <include name="**/*.*"/> 
     </fileset> 
</copy> 
</target> 

<target name="deploywar" depends="build" description="Deploy application as a WAR file"> 
    <war destfile="${name}.war" 
     webxml="${web.dir}/WEB-INF/web.xmL"> 
     <fileset dir="${web.dir}"> 
      <include name="**/*.*"/> 
     </fileset> 
    </war> 
    <copy todir="${deploy.path}" presevelastmodified="true"> 
     <fileset dir="."> 
      <include name="*.war"/> 
     </fileset> 
    </copy> 
</target> 

<!-- Tomcat tasks --> 

<path id="catalina-ant-classpath"> 
    <fileset dir="/usr/local/Cellar/tomcat/8.5.3/libexec/lib"> 
     <include name="catalina-ant.jar"/> 
     <include name="tomcat-coyote.jar"/> 
     <include name="tomcat-util.jar"/> 
    </fileset> 
    <fileset dir="/usr/local/Cellar/tomcat/8.5.3/libexec/bin"> 
     <include name="tomcat-juli.jar"/> 
    </fileset> 
</path> 

<taskdef name="install" classname="org.apache.catalina.ant.DeployTask"> 
    <classpath refid="catalina-ant-classpath"/> 
</taskdef> 
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"> 
    <classpath refid="catalina-ant-classpath"/> 
</taskdef> 
<taskdef name="list" classname="org.apache.catalina.ant.ListTask"> 
    <classpath refid="catalina-ant-classpath"/> 
</taskdef> 
<taskdef name="start" classname="org.apache.catalina.ant.StartTask"> 
    <classpath refid="catalina-ant-classpath"/> 
</taskdef> 
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask"> 
    <classpath refid="catalina-ant-classpath"/> 
</taskdef> 

<target name="install" description="Install application in Tomcat"> 
    <install url="${tomcat.manager.url}" 
     username="${tomcat.manager.username}" 
     password="${tomcat.manager.password}" 
     path="/${name}"/> 
</target> 

<target name="reload" description="Reload application in Tomcat"> 
    <install url="${tomcat.manager.url}" 
     username="${tomcat.manager.username}" 
     password="${tomcat.manager.password}" 
     path="/${name}"/> 
</target> 

<target name="start" description="Start application in Tomcat"> 
    <install url="${tomcat.manager.url}" 
     username="${tomcat.manager.username}" 
     password="${tomcat.manager.password}" 
     path="/${name}"/> 
</target> 

<target name="stop" description="Stop application in Tomcat"> 
    <install url="${tomcat.manager.url}" 
     username="${tomcat.manager.username}" 
     password="${tomcat.manager.password}" 
     path="/${name}"/> 
</target> 

<target name="list" description="List application in Tomcat"> 
    <list url="${tomcat.manager.url}" 
     username="${tomcat.manager.username}" 
     password="${tomcat.manager.password}"/> 
</target> 

<!-- End Tomcat tasks --> 

springapp/build.properties:

#Ant properties for building the springapp 

appserver.home=/usr/local/Cellar/tomcat/8.5.3/libexec 

appserver.lib=${appserver.home}/lib 

deploy.path=${appserver.home}/webapps 

tomcat.manager.url=http://localhost:8080/manager/text 
tomcat.manager.username=tomcat 
tomcat.manager.password=s3cret 

springapp /戦争/ index.jspを

<html> 
    <head><title>Example :: Spring Application</title></head> 
    <body> 
     <h1>Example - Spring Application</h1> 
     <p>This is my test.</p> 
    </body> 
</html> 

springapp /戦争/ WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.4" 
xmlns="httpL//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"> 

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

</web-app>" 
+0

* "何をすべきかわかりません" * Tomcatのログファイルを見て、Webアプリケーションの起動を妨げたエラーを確認します。 – Andreas

+0

コントローラをポストする – bmarkham

+0

@bmarkham - この時点でチュートリアルで指定されているコントローラーはありません – todon2

答えて

1

@残念ながら、ログを確認するために記載されています。

いくつかのTomcatログファイルがありますが、私が最も有用であり、ほとんどの情報はcatalinaでした。 の日付 .log。それはスタックトレースを示し、私は最後にweb.xmlファイルのタイプミスを突き止めることができました。

私が誤字を解決した後、私はindex.jspに正常にアクセスできました。

関連する問題