Automatic completion of JS -- automatically complete the previous Javascript

Source: Internet
Author: User

Technical Exchange is welcome. QQ: 138986722

In the article "javascript auto-completion", store the "Color Set" with an array, compare it with the value entered by the user, and replace the value of the array this time. Ajax is used to interact with background data, and the previous code is not much said. The database uses Oracle10g. JS uses a framework called jquery (1.4.2 ). The background framework uses SSH ~~~ This ssho (zookeeper) O
Alas !!!

The auto-completion I wrote is basically a waste product. I hope I can see some of my views on auto-completion, whether it is SQL statements, database design, and then program design. and so on.

Database Design:

-- Create a table, auto-increment with ID as the primary key, keyword input with title as the user, and clicks as the key. Create Table bms_mate (ID integer primary key, title varchar2 (50 ), clicks number); -- create sequence: -- create sequence bms_mate_sequence minvalue 1 -- Minimum maxvalue 999999999999999999999999999 -- maximum start with 1 -- increment by 1 -- cache 20 from; insert into bms_mate values (bms_mate_sequence.nextval, 'Dan Dan learn') Select * From bms_mate

Data:

Background code:

Dao layer,

/*** Conditional query */public list <t> getall (string hql, list Params) {query = This. getsession (). createquery (hql); If (null! = Params & Params. size ()> 0) {// returns the value of for (INT I = 0; I <Params. size (); I ++) {query. setparameter (I, Params. get (I) ;}}list <t> List = query. list (); return list ;}

Biz Layer

public List getBmsAll(String title) throws Exception {  String hql = "select title from BmsMate where title like ? order by clicks desc";  List params = new ArrayList();  params.add(title+"%");  return baseDao.getAll(hql,params); }

 

Action

Package COM. boxun. action; import Java. io. printwriter; import Java. util. list; import javax. servlet. HTTP. httpservletrequest; import javax. servlet. HTTP. httpservletresponse; import Org. apache. struts2.interceptor. servletrequestaware; import Org. apache. struts2.interceptor. servletresponseaware; import COM. boxun. biz. iajaxbiz; import COM. opensymphony. xwork2.actionsupport; public class ajaxation extends actionsupport Implements servletrequestaware, servletresponseaware {/* httpservletrequest object */private javax. servlet. HTTP. httpservletrequest request; private javax. servlet. HTTP. httpservletresponse response; private iajaxbiz ajaxbiz; Public void setajaxbiz (iajaxbiz ajaxbiz) {This. ajaxbiz = ajaxbiz;} public void setservletrequest (httpservletrequest request) {This. request = request;} public void setservletresponse (HTTP Servletresponse response) {This. response = response;}/*** query matched item * 10:05:37 * @ return */Public String gettitle () {printwriter out = NULL; response. setcharacterencoding ("UTF-8"); try {out = response. getwriter (); String title = request. getparameter ("Colors"); If (Title = NULL | title. equals ("") {out. print ("error"); return NULL;} List list = ajaxbiz. getbmsall (title); string result = ""; for (Object OBJ: List) {result + = "," + obj. tostring ();} If (result! = NULL &&! "". Equals (result) out. print (result. substring (1); elseout. print ("");} catch (exception ex) {out. print ("error"); Ex. printstacktrace ();} finally {If (OUT! = NULL) Out. Close () ;}return null ;}}

Struts Configuration:

<action name="jqueryAjax" class="ajaxAction"> <result></result> </action>

Page code:

<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" UTF-8 "%> <% string Path = request. getcontextpath (); string basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/"; %> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"> <HTML> 

Run:

Only the findcolors () method has been modified, and others have not been changed ~~~!!!

When clicking a value here, you should add 1 to the clicks field in the background. I haven't done it yet. The other is if I have millions, tens of millions, or even hundreds of millions of data records. what should I do!

How can we optimize this? I hope you can tell me what you want to know. Thank you !!!

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.