2017-08-10 15 views
0

私は初心者です。私は以下のプログラムをコーディングしようとしましたが、404エラーが出ています。私は、正確なエラーが要求されたリソースが利用できない春のMvc学生登録フォーム

message /submitAdmissionForm.html 

説明

throwing HTTP Status 404 - /submitAdmissionForm.html. 
HTTP Status 404 - /submitAdmissionForm.html 

タイプステータスレポートここで追跡することができません。

enter image description here

のApache Tomcat/8.0.28


私のファイル:

ウェルカムページ -

<html> 
<body> 
    <h3> STUDENT ADMISSION FORM FOR ENGINEERING COURSES</h3> 

    <form action="/submitAdmissionForm.html" method="post"> 
     Student's Name : <input type="text" name="studentName" /> 
     Student's Hobby :<input type="text" name="studentHobby" /> 
     Student's Mobile :<input type="text" name="studentMobile" /> 
     Student's DOB :<input type="text" name="studentDOB" /> 
     Student's Skills set 
     <select name="studentSkills" > 
     <option value="Java Core">Java Core</option> 
     <option value="Spring Core">Spring Core</option> 
     <option value="Spring MVC">Spring MVC</option> 
     </select> 
     Student's Address : 

      country: <input type="text" name="studentAddress.country"/> 
      city: <input type="text" name="studentAddress.city" /> 
      street: <input type="text" name="studentAddress.street" /> 
      pincode:<input type="text" name="studentAddress.pincode" /> 
     <input type="submit" value="Submit this form by clicking here" /> 
    </form> 

</body> 
</html> 

たindex.jsp

記述 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" 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>praygod</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> 
<servlet-name>student</servlet-name> 
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
</servlet> 
<servlet-mapping> 
<servlet-name>student</servlet-name> 
<url-pattern>/</url-pattern> 
</servlet-mapping> 

</web-app> 

学生-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans  
     http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc.xsd"> 


    <context:component-scan base-package="com.gappu.student" /> 
    <mvc:annotation-driven/> 

    <bean id="viewResolver" 
     class="org.springframework.web.servlet.view.InternalResourceViewResolver" > 
     <property name="prefix"> 
      <value>/WEB-INF/</value> 
     </property> 
     <property name="suffix"> 
      <value>.jsp</value> 
     </property> 
</bean> 


</beans> 

Controller.java

package com.gappu.student; 

import org.springframework.stereotype.Controller; 
import org.springframework.validation.BindingResult; 
import org.springframework.web.bind.annotation.ModelAttribute; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RequestMethod; 
import org.springframework.web.servlet.ModelAndView; 


@Controller 
public class studentcontroller { 



    @RequestMapping(value="/submitAdmissionForm.html", method = RequestMethod.POST) 
    public ModelAndView submitAdmissionForm() { 



     ModelAndView model1 = new ModelAndView(); 
     model1.setViewName("AdmissionSuccess"); 
     return model1; 
    } 



} 

は、ここで私はこのプログラムを実行しようとすると、404URLが存在していない提案として、それは私にエラーを与える

AdmissionSuccess.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
     pageEncoding="ISO-8859-1"%> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
    <title>Insert title here</title> 
    </head> 
    <body> 
    Hello there 
    </body> 
    </html> 

私の成功のページです。

+0

tomcatが起動すると、tomcatの完全なログを貼り付けてください。 –

+0

返信ありがとうございます。ログにエラーはありません。サーバーログのイメージを追加しました。確認してください。 –

+0

リソースに問題がある可能性があります。フォームアクションとコントローラのマッピングから '.html'を削除してください。また、実際のリソースがある場所を指すように ''をサーブレットxmlに追加してみてください – StanislavL

答えて

1

あなたのプロジェクトにはすべてのライブラリが含まれていないというのが問題だと思います。 EclipseとMavenを使用している場合は、

プロジェクトプロパティ - >デプロイメントアセンブリ - >追加 - > Javaビルドパスエントリ - > Maven依存関係を参照してください。