Gets the maximum field value in the table and saves it in the foreground page

Source: Internet
Author: User

Get Useridfunction getUserId () {     $.getjson (' <%=basepath%>user/getuserid.do ',        function (data) {            Alert (eval (data). userId);            document.getElementById ("UserId"). Value=data.userid;    });       


<input id= "userid" name= "userid" value= "" type= "text" readonly= "readonly"/><input value= "Get maximum UserId" onclic K= "Javascript:getuserid ();" type= "button" style= "width:100px"/>

Userslavecontroller Getting parameters

@ResponseBody//@ResponseBody Returns the data, without @ResponseBody the page is returned. @RequestMapping (value= "/user/getuserid.do")//method=requestmethod.postpublic jsonobject getUserId (    HttpServletRequest request, HttpServletResponse response) throws Exception {Response.setcontenttype ("text/html");    Request.setcharacterencoding ("Utf-8");    Response.setcharacterencoding ("Utf-8");        Jsonobject jsonobject = new Jsonobject ();        Integer userId = 0;                   try {userId = Userslaveservice.getuserid ();        } catch (Exception e) {loger.logtxt ("user", "Get ID Exception:" + e.tostring ());        } jsonobject.accumulate ("userid", UserID);     System.out.println (Jsonobject.tostring ());       Output: {"UserId": 182888} System.out.println (Jsonobject.values ());                             Output: [182888] return jsonobject; Returns the JSON, receives it in the JSP page above, and saves the value into input. }

Userslaveservice.java Interface declaration method: public Integer GetUserId () throws Exception;

Userslaveserviceimpl.java implements the Userslaveservice interface:

@Override
Public Integer GetUserId () throws Exception {
return Userdao.getuserid ();
}

Iuserdao.java Interface declaration method: public Integer GetUserId () throws Exception;

Queries in User.xml:

<select id= "GetUserId" resulttype= "Java.lang.Integer" >

<! [cdata[
SELECT (MAX (userid) +1) as UserID from UserInfo
]]>

  

Gets the maximum field value in the table and saves it in the foreground page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.