Packaging process
Make the website program into a war package, using clean packages;
Place the war packet in the WebApps on the server's Tomcat;
Change the Server.xml file in the Conf directory:
Add the following code, change the encoding method, prevent garbled
Uriencoding= "UTF-8"
<connector port= "8080" protocol= "http/1.1" uriencoding= "UTF-8" connectiontimeout= "20000" re directport= "8443"/>
There are tomcat access records under the logs directory , as follows:
[Email protected] logs]# Lscatalina.2015-08-14.log host-manager.2015-08-14.log Localhost_access_ Log.2015-08-14.txtcatalina.out Localhost.2015-08-14.log Manager.2015-08-14.log
Localhost_access_log.2015-08-14.txt
This is the record access, which has the input record value for analysis.
In order to facilitate statistics, to change the Server.xml, the change is the log file , as follows:
<valve classname= "Org.apache.catalina.valves.AccessLogValve" directory= "Logs" prefix= "Hadoop11_access_log . "suffix=". txt "filedateformat=" yyyy-mm-dd-hh-mm "pattern="%h%l%u%t "%r" %s%b "/>
prefix is the prefix, suffix is the suffix, filedataformat is the frequency
Use Ajax to trigger an asynchronous request, as follows:
Using the AutoComplete plug-in of jquery, the request is sent back to the URI in the background, and the server returns a JSON-structured data message to the foreground, which is displayed on the page.
<script type= "Text/javascript" > $ (document). Ready (function () { $ ("#query"). AutoComplete ({ source : function (Request, response) { $.ajax ({ //here is the processing class for the request server url : "Http://hadoop11:8080/web/suggest.do", //Here's datatype is response back to the data structure datatype : " JSON ", //data is the transfer of past data data : { query : $ ("#query"). Val () }, If //responds successfully, success success : function ( Data) { //is looking for the class in action, the result property inside the class, is a set set &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;//is returned here is a collection, Return to the structure of JSON In //struts2, objects added to the value stack are assigned a get assignment to the property, and then the required method is executed response ($.map (data.result, function (item) { return {value:item} })); } }); }, minLength:1, }); });</script>
public class SearchAction extends Actionsupport {String text; String query; set<string> result; Public set<string> GetResult () {//this.result = redistool.zrevrange (query, 0, 5); result = new hashset<string> (); Result.add ("AAA"); Result.add ("Sub"); return result; } 。。。。。。 。。。。。
The class here corresponds to the result above.
Required Scripts
<script type= "Text/javascript" src= "Http://code.jquery.com/ui/1.9.2/jquery-ui.js" ></script>
The UI is also dependent on:
<script src= "//cdn.bootcss.com/jquery/1.11.3/jquery.min.js" ></script>
When using Redis, use the sort arrangement to insert an index;
The Hgetall key, which is the list of all values under the key.
Pass a value through query: Returns a set set after a query by Redis.
Public static set<string> zrevrange (STRING&NBSP;TEXT,&NBSP;INT&NBSP;I,&NBSP;INT&NBSP;J) { // todo auto-generated method stub try{ createjedisobj (); // hadoop_users return jedis.zrevrange (text, 0, 5); }catch (exception e) { e.printstacktrace (); jedis = null; return null; } }
The operation of Redis can be familiar.
In the actual development, the Redis database update can be updated one by one, in the process of reduce to delete the original Redis data records.
Learning Log---Creating search tips for search engines