2012-07-24 17 views
9

私はEclipseの動的Webプロジェクトで作成しましたが、WEB-INFフォルダにindex.htmlがあります。プロジェクトのメインフォルダをクリックしてください。Run as>サーバーで実行すると、Tomcat v7.0が選択され、終了し、OKを実行します。しかし、index.htmlの名前を別の名前に変更すると、メッセージが表示されます。EclipseダイナミックWebプロジェクト - デフォルトの開始ページ

要求されたリソース(/ MyProject /)は使用できません。

  1. どのようにデフォルトページを変更できますか?
  2. 私はデフォルトページのASPファイルに置くことができますか?

私の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>MyFirstServlet</display-name> 
    <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 
    <servlet> 
    <description>new</description> 
    <display-name>GrettingServlet</display-name> 
    <servlet-name>GrettingServlet</servlet-name> 
    <servlet-class>GrettingServlet</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>GrettingServlet</servlet-name> 
    <url-pattern>/GrettingServlet</url-pattern> 
    </servlet-mapping> 
</web-app> 

答えて

14

(TOMCAT_HOME/webappsに下/ you_application)あなたがこれを持っている:

<welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
    <welcome-file>/axis2-web/index.jsp</welcome-file> 
    </welcome-file-list> 

新しいファイル名に変更し

+1

index.htmlが見つからない場合は次のように進むなどです。 – URL87

3

がいくつかチェックします。

1) Servlet mapping extension in web.xml 
2) Welcome file definition in web.xml 

あなたが変更と拡張&名前があることを確認してください。

web.xmlは、WEB-INFフォルダ内になります。 web.xmlに

+1

私はTomcat 7で作業すればどこにでもそこにweb.xmlがありますか? – URL87

+1

web.xmlはプロジェクト---> WEB-INFフォルダ内にあります。存在しない場合は、作成してウェルカムファイル定義を追加する必要があります。 – kosa

4

1)どのようにして、デフォルトのページを変更することができますか?

=> web.xmlのウェルカムファイルリストを変更します。使用しているファイル名に変更してください。

2)デフォルトページのASPファイルを置くことはできますか?

=>拡張子をaspに変更できますが、web.xmlにサーブレットマッピングが必要です。あなたがMicrosoft ASP pagesについて話している場合しかし、私はあなたが両方としての私の知識(JSPおよびASP)ごとにそれらを追加することができなくなると思うが、異なる技術

の下にある

EDIT:ここ

<?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>MyFirstServlet</display-name> 
    <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 
    <servlet> 
    <description>new</description> 
    <display-name>GrettingServlet</display-name> 
    <servlet-name>GrettingServlet</servlet-name> 
    <servlet-class>GrettingServlet</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>GrettingServlet</servlet-name> 
    <url-pattern>/greetings.asp</url-pattern> 
    </servlet-mapping> 
</web-app> 

あなたはGreetingServletにURLを使ってリクエストをしますhttp://localhost:8080/myapp/greetings.asp

+1

私はサーブレットマッピングで何を書かなければならないのか説明できますか?投稿を編集してweb.xmlを追加しました。 – URL87

+1

@ URL87:updated Answer –

+0

@NandkumarTekaleコメントを書いてお手数ですが、ご迷惑をおかけして申し訳ございません。質問を書いても閉鎖されます。私はサーブレットとJSPを使ってプロジェクトを開発しましたが、今は何を実行するのか混乱していますアプリケーションを起動します。私はJSPを実行する場合、サーブレットから来るはずのデータは、私がサーブレットを実行するときに再度ロードされていないeverthingが実行されますが、JSPのJavaScript関数はほとんど呼び出されません。ここで私の混乱は、アプリケーションを起動するために実行する必要があります、私はJSPを既定のページまたはサーブレットとして既定のページとして実行する必要があり、何が示唆されたアプローチです。 – Siva

関連する問題