lundi 2 mars 2015

Controller does not accept data POST 404

Help me please, I'm writing a site on java ee with spring mvc, I need to send the request to the servlet, but I get error 404.


my html:



<input type="button" value="add" onclick="sendRequest()">


my js:



function sendRequest(){
var str = "this is string";
$.ajax({
url:"ajaxtest",
type:"POST",
//data:JSON.stringify(myJson).toString(),
data:str,
success: alert("good")
});}


my controller:



@RequestMapping(value="ajaxtest", method=RequestMethod.POST)
public void getAjax(String myStr){
System.out.print("result : "+myStr);
}


result console browser:



POST http://localhost/MyProject/ajaxtest 404 (Not Found)
m.ajaxTransport.send - jquery-1.11.2.min.js:4
m.extend.ajax - jquery-1.11.2.min.js:4
sendRequest - add.jsp:139
onclick - add.jsp:213


result console ide:



INFO: Server startup in 2991 ms
result : null


Please help me!


Aucun commentaire:

Enregistrer un commentaire