私自身のWebアプリケーション(Java、SpringMVC、Hibernate)を構築しようとしています。 サンプルプロジェクトが完了しました。技術仕様:Mavenの、Eclipseの酸素IDE、Tomcatの9 私は右のプロジェクトをクリック - > [ファイル名を指定して実行 - サーバー上> Runの私は以下のエラーを取得しています:私はURLを打ったときTomcatサーバーがEclipse経由で動作していますが、私のホームページで404エラーが発生しています
Description: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
同じことがhttp://localhost:8080/mavenWebApp/getAllCountries(たまたま)
しかし、私がTomcatのデフォルトページ(http://localhost:8080)を押すと、正常に動作します。
私のコントローラクラス
@RequestMapping(value="/getAllCountries", method = RequestMethod.GET, headers="Accept=application/json")
public String getCountries(Model model) {
List listofCountries = countryService.getAllCountries();
model.addAttribute("Country", new Country());
model.addAttribute("listOfCountries", listofCountries);
return "countryDetails";
}
春-servlet.xml
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
私は、WEB-INF /ビュー/フォルダにcountryDetails.jspを持っています。
私の完全なweb.xmlの
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationcontext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
私は、このケースではapplicationContext.xmlを、私はそれのために作成した空のファイルであるため、春-servlet.xmlに豆の設定を行っています。
私のコードの他の部分を貼り付けるかどうかお知らせください。 そうでなければ通常のTomcat-Installation-Folder/logsではサーバーログが更新されていません。なぜ私は分からない。
P.S.私は、サーバーのプロパティ - >一般 - >ワークスペースメタデータを/ Servers/Tomcat v9.0 Serverに切り替えようとしました。 そしてほとんどすべての他のソリューションは以前から提供されていませんでした。
質問している内容が分かりません – Ravi
My Tomcatサーバーが起動しており、既定のページも正常に読み込まれています。しかし私が私のプロジェクトを実行しようとすると、404エラーが表示されます。説明:元のサーバーがターゲットリソースの現在の表現を見つけられなかったか、またはそれが存在することを公開する意思がありません。 – Guru
誰かが手を差し伸べてもらえますか?これは私の最初のプロジェクトであり、私が枯渇したようです。 – Guru