After an article, this morning to achieve the increase in data. Here is the JSP, which is mainly looking at NewUser () and Saveuser (). Notice that the Url,newuser () inside this function takes away the URL attribute. One more thing to keep in mind
<div id= "Toolbar" ><a href= "javascript:void (0);" class= "Easyui-linkbutton" iconcls= "Icon-add" plain= "true" Onclick= "NewUser ()" >new user</a><a href= "#" class= "Easyui-linkbutton" iconcls= "Icon-edit" plain= "true" Onclick= "Edituser ()" >edit user</a><a href= "#" class= "Easyui-linkbutton" iconcls= "Icon-remove" plain= " True "onclick=" Removeuser () ">remove user</a></div>
In this, <a href= "#" > # to be changed to Javvascript:void (0); This does not occur when the page is not found when the new user is created.
<%string path = Request.getcontextpath (); String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >Package Com.yang.bishe.controller;import Java.util.list;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.httpservletresponse;import Org.springframework.beans.factory.annotation.autowired;import Org.springframework.stereotype.controller;import Org.springframework.web.bind.annotation.requestmapping;import Org.springframework.web.bind.annotation.responsebody;import Org.springframework.web.servlet.modelandview;import Com.yang.bishe.entity.json;import Com.yang.bishe.entity.user;import Com.yang.bishe.service.interfaces.IUserService; @Controller @requestmapping ("/user") public class Usercontroller Extends Basecontroller {@Autowiredprivate iuserservice userservice; @RequestMapping ("/list") public Modelandview Golist () {return new Modelandview ("User/list"); } @RequestMapping ("/listusers") public String Listuser (httpservletrequest request,httpservletresponse response) Throws Exception {//return "/views/index"; String hql= "from User"; List<user>users=userservicE.find (HQL);//string result=userservice.find (HQL); Writejson (users,response); return null; } @RequestMapping ("/adduser") public String addUser (User user,httpservletrequest request,httpservletresponse response ) throws Exception{json JSON = new JSON ();//used to send messages to the front End if (Userservice.getbyid (User.getuserid ())!=null) {json.setmsg (" New user failed, user already exists! ");} Else{userservice.save (user); Json.setmsg ("New user succeeded! "); Json.setsuccess (true);} Writejson (json,response); return null;}}
Writejson (Json,response)
This is to pass the message to the front page, Success:funciont (result) in the function inside the script, and result has the JSON message in the controller.
Springmvc+easyui CRUD Add Data C