java - HTTP/1.1 404 Not Found - JSON Spring MVC -
i write 1 webapp,i seek send 1 json server , save mysql. i've got problem:
post http://localhost:8080/jsonspringhibernateexample/addclass [http/1.1 404 not found 910ms]
this controller (use add together 1 class mysql):
@controller public class classcontroller { @autowired private classservice classservice; @requestmapping(value ="/index",method = requestmethod.get) public string getindex(modelmap map){ map.put("listclass",classservice.getlistclass()); map.put("studentclass", new class()); homecoming "class"; } @requestmapping(value ="/addclass", method = requestmethod.post) public string addclass(@requestbody class studentclass){ classservice.addclass(studentclass); homecoming "index"; } }
this jquery phone call controller:
$("#addclass").click(function(e){ $.ajax({ url:"addclass", type: "post", contenttype: 'application/json', data: json.stringify({classname:$("#input").val(),liststudent:null}), }).done(function(){ $("#listclass").appent("<option>"+$("#input").val()+"</option>"); }); });
when click "#addclass" button, class added controller not homecoming index.jsp, , got trouble. why error? , how can solve it? thanks!
do have @requestmapping(value="/jsonspringhibernateexample")
before controler class ? else seek remove headers = {"content-type=application/json"}
, maybe content-type wrong (but i'm not sure).
java jquery mysql json spring
No comments:
Post a Comment