Bonjour,
J'ai un controller
Au niveau de la jsp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 @Controller //@SessionAttributes("roles") @SessionAttributes({"roles", "postes","users"}) public class MsgerieController { @RequestMapping(value = "/getMessagebyId", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE }) public @ResponseBody String validateCaptchaThroughAJAX(@RequestBody String id) throws IOException { System.out.println("getMessagebyId Spring Mvc ************************** "); System.out.println("getMessagebyId Spring Mvc JQuery message id : " + id); return "done"; } }
Code JavaScript : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 function fbReadMsg(id) { alert('fbReadMsg id : ' + id ); //var idObj = JSON.stringify(id); //searchViaAjax(id); //var json = {id : id}; var data = {}; data["id"] = id; $.ajax({ url: "getMessagebyId", type: 'POST', //data: JSON.stringify(json), data : JSON.stringify(data), dataType : 'json', cache:false, contentType : "application/json", /*beforeSend: function(xhr) { xhr.setRequestHeader("Accept", "application/json"); xhr.setRequestHeader("Content-Type", "application/json"); },*/ success:function(data){ alert("Success : " + data); }, error:function(jqXhr, textStatus, errorThrown){ alert(textStatus); } });
a l'exécution , j'ai le message
déc. 05, 2019 8:48:32 AM org.springframework.web.servlet.PageNotFound noHandlerFound
AVERTISSEMENT: No mapping found for HTTP request with URI [/SyGACUT/getMessagebyId] in DispatcherServlet with name 'dispatcher'
Partager