そのため、作成したSpring /サーブレットベースのJavaアプリケーションからWebページを読み込もうとしましたが、毎回HTTPステータス404 – Not Foundエラーが発生し続けますが、すべてのxmlサーブレットマッピングとJavaを接続したことは確かです正しくコーディングします。404 をロードするフロント エンド Web ページ以外にバックエンド エラーはポップアップ表示されず、「The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
エラーはなく、xml 用に設定したパスは問題ないように見えるので、コードでパスのマッピングに問題がある理由がわかりません」実際のjspファイル自体に。これまでの私のプロジェクト構造とコードは次のとおりです
web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>spring-mvc-demo</display-name>
<!-- Step 1: Configure Spring MVC Dispatcher Servlet -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc-demo-servlet.xml</param-value>
</init-param>
</servlet>
<!-- Step 2: Set up URL mapping for Spring MVC Dispatcher Servlet -->
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
spring-mvc-demo-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- Step 3: Add support for component scanning -->
<context:annotation-config/>
<context:component-scan base-package="com.christien" />
<!-- Step 4: Add support for conversion, formatting and validation support -->
<mvc:annotation-driven/>
<!-- Step 5: Define Spring MVC view resolver -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
HelloWorldController.java
package com.christien;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HelloWorldController {
@RequestMapping("/")
public String index(){
return "index";
}
//controller method to show the initial form
@RequestMapping("/showForm")
public String showForm(){
return "helloworld-form";
}
//controller method to process the form
@RequestMapping("/processForm")
public String processForm(){
return "helloworld";
}
}
私が間違っていることについて誰かが私を助けてくれたり、別の便利なスタック投稿にリダイレクトしたりすることができれば、ありがとう!