SSH and mobile to implement additions and deletions to check the interface

Source: Internet
Author: User

One: Query

1.action

public void mtadopt () {
HttpSession session = Servletactioncontext.getrequest (). GetSession ();
HttpServletResponse response = Servletactioncontext.getresponse ();
HttpServletRequest request = Servletactioncontext.getrequest ();
String id=request.getparameter ("id");
SYSTEM.OUT.PRINTLN ("The ID value is" +id);
String[] Values=new String[]{id};
SYSTEM.OUT.PRINTLN (1);
String hql= "Select S from Smrz s where s.idcard=?";
SYSTEM.OUT.PRINTLN (2);
List<smrz> mtadopt= (list<smrz>) sharedfarmadminmanager.mtadopt (hql,values);
SYSTEM.OUT.PRINTLN (3);
SYSTEM.OUT.PRINTLN ("Data" +mtadopt.size ());
SYSTEM.OUT.PRINTLN (4);
Gson Gson = new Gson ();
SYSTEM.OUT.PRINTLN (5);
String json = Gson.tojson (mtadopt.get (0));
SYSTEM.OUT.PRINTLN (6);
PrintWriter out = null;//stream
try {
out = Servletactioncontext.getresponse (). Getwriter ();
} catch (IOException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
Response.setheader ("Cache-control", "No-cache"); Canceling the browser cache
System.out.println ("This is?" "+json);
Out.print (JSON);
Out.flush ();
Out.close ();//Close stream
}

2. Interface

Public list<?> mtadopt (String hql, object[] values);

3 Interface Implementation Class

@Override
Public list<?> mtadopt (String hql, object[] values) {
List list= null;
Query query = this.getsession (). CreateQuery (HQL);
if (query! = NULL && values! = null && values.length > 0) {
for (int i = 0; i<values.length; i++) {
Query.setparameter (i, values[i]);
}
}
List = Query.list ();
return list;
}

SSH and mobile to implement additions and deletions to check the interface

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.