When I started write application, form submited and createAnnotation method worked. Now it doesn't work. Why? By the way GET method executes in controller, and POST doesn't.
@Controller
@RequestMapping("/annotation")
public class AnnotationController {
@RequestMapping(value = "/new", method = RequestMethod.POST)
public String createAnnotation(@ModelAttribute Annotation annotation, BindingResult result){
annotationService.create(annotation);
return "redirect:/annotation/annotations.htm";
}
}
<form action="${pageContext.request.contextPath}/annotation/new" method="post">
<div class="form-group">
<label for="text">Annotation name</label>
<input type="text" class="form-control" id="text" placeholder="Annotation name" name="name"/>
</div>
<div class="form-group">
<label for="date">Date:</label>
<input type="date" class="form-control" id="date" placeholder="Date" name="date"/>
</div>
<div class="form-group">
<label for="comment">Description:</label>
<textarea class="form-control" rows="5" id="comment" name="description"></textarea>
</div>
<input type="hidden" name="profil.id" value="1"/>
<input type="submit" class="btn btn-default" value="Submit"/>
</form>
I don't know why, but when i've added this code in form tag, all fixed
<input type="hidden" name="${_csrf.parameterName}"
value="${_csrf.token}" />
wTf???
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.