2017-07-30 5 views
1

下記のjspフォームを送信すると、送信されず、コンソールに何も表示されません。 ブラウザでエラーのあるHTTP 404ステータスが表示されます。クライアントから送信されたリクエストが構文的に正しくありません。構文上の誤りがあります:spring mvc

私のJSPページです:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
pageEncoding="ISO-8859-1"%> 
<%@ page isELIgnored="false" %> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

<html> 

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Add task</title> 
<link href="<c:url value='/static/css/bootstrap.css' />" rel="stylesheet"> 
</link> 
<link href="<c:url value='/static/css/app.css' />" rel="stylesheet"></link> 
<c:set var="root" value="${pageContext.request.contextPath}"/> 
</head> 

<body> 
<div class="generic-container"> 

    <div class="well lead">Add task</div> 
    <form class="form-horizontal" action='<c:url value="addTask"/>'> 
     <input type="hidden" name="id" id="id"/> 

     <div class="row"> 
      <div class="form-group col-md-12"> 
       <label class="col-md-3 control-lable" 
for="taskDescription">Task name</label> 
       <div class="col-md-7"> 
        <input type="text" name="task" id="task" class="form- 
control input-sm"/> 
        <div class="has-error"> 
        </div> 
       </div> 
      </div> 
     </div> 

     <div class="row"> 
      <div class="form-group col-md-12"> 
       <label class="col-md-3 control-lable" 
for="taskDescription">Task Description</label> 
       <div class="col-md-7"> 
        <input type="text" name="taskDescription" 
id="taskDescription" class="form-control input-sm" /> 
        <div class="has-error"> 
        </div> 
       </div> 
      </div> 
     </div> 


     <div class="row"> 
      <div class="form-group col-md-12"> 
       <label class="col-md-3 control-lable" for="fromTime">From 
Time</label> 
       <div class="col-md-7"> 
        <input type="text" name="fromTime" id="fromTime" 
class="form-control input-sm" /> 
        <div class="has-error"> 
        </div> 
       </div> 
      </div> 
     </div> 

     <div class="row"> 
      <div class="form-group col-md-12"> 
       <label class="col-md-3 control-lable" for="toTime">To 
Time</label> 
       <div class="col-md-7"> 
        <input type="text" name="toTime" id="toTime" 
class="form-control input-sm" /> 
        <div class="has-error"> 
        </div> 
       </div> 
      </div> 
     </div> 



     <div class="row"> 
      <div class="form-actions floatRight"> 
         <input type="submit" value="Add" class="btn btn- 
primary btn-sm"/> 
      </div> 
     </div> 
    </form> 
</div> 
</body> 
</html> 

要求を処理するためのコントローラのアクションは、/ addTaskが

import org.springframework.stereotype.Controller; 
import org.springframework.web.bind.annotation.ModelAttribute; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RequestMethod; 

import com.websystique.springmvc.model.AddTask; 
import com.websystique.springmvc.service.TaskService; 

@Controller 
@RequestMapping("/") 
public class AddTaskController { 

private TaskService taskService; 

@RequestMapping("/task") 
String task(){ 
    System.out.println("Inside task action"); 
    return "addTask/addTask"; 
} 

@RequestMapping("/addTask") 
String addTask(@ModelAttribute AddTask a){ 
    System.out.println("Inside addTask action"); 
    this.taskService.addTask(a); 
    return "redirect:/task" ; 
} 

} 

AddTaskController

である私は、追加のタスクフォームを送信すると、エラーが表示されます。 要求クライアントによって送信された構文が正しくない

+0

コントローラクラスとadf a/in c:url _/addTask_ – kimy82

答えて

0

<body> 
<div class="generic-container"> 

    <c:url var="addTask" value="/addTask"/> 

    <div class="well lead">Add task</div> 
    <form class="form-horizontal" action="${addTask}"> 
+0

のリクエストマッピングを削除してみてください。この方法でも動作しません。 –

関連する問題