02.商品分类选择-分析-前端js_

03.商品分类选择-分析-数据库_

(JJTree渲染过程解析(parent_id为0就是父节点,is_parent为1说明下面有子节点,state1正常2删除。tree组件有ztree,异步控件树每个节点都有id,展开节点向服务端发送请求,请求检索子节点列表,参数当前节点的id,服务端响应json数据,)&)

04.商品分类选择-Service_

05.商品分类选型实现_

(使用@RequestParam获取参数(@RequestParam(name=”id”,defaultValue=”0” )第一次请求不带参数,给一个默认值确保肯定有值)&)

06.图片上传分析及图片服务器配置_

(Socket选项 HTTP服务器(开启虚拟机,选择已移动该虚拟机保留原来网路配置不发生变化,复制重新生成网卡原来配置不生效,如果要使用虚拟机通过设置为NAT模式,并设置子网网段)&高可用的分布式文件系统构建(只有一个工程把图片放在工程目录下,在1000并发的时候到达tomcat集群,通过Nginx转发每一个tomcat部署一个应用程序,通过轮询把请求平均分给不同服务器,为了能够保证在不同服务器都能找到目标图片需要专门有一个分布式文件服务器FastDFS(软件分布式文件系统,允许横向扩容与负载均衡保证高性能与高可用)负责图片存放与http图片访问(http服务器可以使tomcat或者是nginx(用于访问静态资源性能较好)))&Nginx 安装及负载均衡配置&)

07.FastDFS上传图片测试_

(跟踪服务器配置(fastDFS没法从中央仓库获取,通过maven工程导入,)&存储节点配置(创建一个资源文件client.conf 配置fastDFS中央仓库服务器地址,后缀与源数据详情)&上传文件测试&)

08.FastDFSClient的使用_

(加载资源文件中的图片(this.getClass.getResource(“/”).getPath()取完还是绝对路径,使用全路径复制会有隐藏字符需要去除格式即可。不以’/'开头时,默认是从此类所在的包下取资源,以’/'开头时,则是从ClassPath根下获取。)&)

package testpackage;
public class TestMain {public static void main(String[] args) {System.out.println(TestMain.class.getResource(""));System.out.println(TestMain.class.getResource("/"));}
}
file:/E:/workspace/Test/bin/testpackage/
file:/E:/workspace/Test/bin/

上面说到的【path以’/'开头时,则是从ClassPath根下获取;】在这里就是相当于bin目录(Eclipse环境下)。

如果我们想在TestMain.java中分别取到1~3.properties文件,该怎么写路径呢?代码如下:

package testpackage;public class TestMain {public static void main(String[] args) {// 当前类(class)所在的包目录System.out.println(TestMain.class.getResource(""));// class path根目录System.out.println(TestMain.class.getResource("/"));// TestMain.class在<bin>/testpackage包中// 2.properties  在<bin>/testpackage包中System.out.println(TestMain.class.getResource("2.properties"));// TestMain.class在<bin>/testpackage包中// 3.properties  在<bin>/testpackage.subpackage包中System.out.println(TestMain.class.getResource("subpackage/3.properties"));// TestMain.class在<bin>/testpackage包中// 1.properties  在bin目录(class根目录)System.out.println(TestMain.class.getResource("/1.properties"));}
}

※Class.getResource和Class.getResourceAsStream在使用时,路径选择上是一样的。

Class.getClassLoader().getResource(String path)

path不能以’/'开头时;
path是从ClassPath根下获取;

还是先看一下下面这段代码的输出:

package testpackage;
public class TestMain {public static void main(String[] args) {TestMain t = new TestMain();System.out.println(t.getClass());System.out.println(t.getClass().getClassLoader());System.out.println(t.getClass().getClassLoader().getResource(""));System.out.println(t.getClass().getClassLoader().getResource("/"));//null}
}

输出结果:

class testpackage.TestMain
sun.misc.Launcher$AppClassLoader@1fb8ee3
file:/E:/workspace/Test/bin/
null

从结果来看【TestMain.class.getResource("/") == t.getClass().getClassLoader().getResource("")】

如果有同样的Project结构

使用Class.getClassLoader().getResource(String path)可以这么写:

package testpackage;public class TestMain {public static void main(String[] args) {TestMain t = new TestMain();System.out.println(t.getClass().getClassLoader().getResource(""));System.out.println(t.getClass().getClassLoader().getResource("1.properties"));System.out.println(t.getClass().getClassLoader().getResource("testpackage/2.properties"));System.out.println(t.getClass().getClassLoader().getResource("testpackage/subpackage/3.properties"));}
}

※Class.getClassLoader().getResource和Class.getClassLoader().getResourceAsStream在使用时,路径选择上也是一样的。

09.图片上传功能分析_

10.图片上传功能实现_

(多文件上传1:使用MultipartHttpServletRequest(springMVC需要把commonsi-fileupload两个jar包加到项目中,前端控制器需要配置多媒体解析器MultipartResolver设置默认编码与最大文件大小,通过MultipartFile接收参数,通过@Value加载配置文件的资源,通过Map返回json数据)&单文件上传3:使用MultipartFile结合实体类&通过IOC容器注入Properties类型&placeholder属性&)

11.上传图片功能测试_

12.解决上传图片浏览器兼容性问题_

(使用jackson在服务端将JSON字符串转换成各种Java数据类型(SpringMvc会把对象转为字符串响应浏览器,直接把Map转为json返回String即可)&)

13.富文本编辑器的使用_

(富文本UEditor(富文本编辑器有UEditor、KindEditor、CKEditor都是纯js开发的)&)

14.商品添加功能分析_

15.商品添加-service_

16.商品添加-完成_

02.工程搭建分析_

03.前台系统工程搭建_

(使用URL Rewrite实现网站伪静态(在web.xml中 url-pattern拦截所有*.html 请求网页伪静态,所有url后缀全部改为html,@RequestMapping(“/index”) 通过index.html进行访问。只访问localhost:8080会默认找welcome-file欢迎页index.html 带html后缀去controller匹配)&)

04.首页展示_

05.首页内容管理-数据库分析_

06.内容服务工程搭建_

07.内容分类查询-service_

08.内容分类列表展示_

(@RequestParam注解(与参数名对不上号,使用@RequestParam(“id” ,defaultValue=””)Integer parentId。使用脚本启动服务Maven build clean tomcat7:run )&)

09.内容分类添加-js分析_

10.内容分类添加-mapper_

11.内容分类添加-service_

12.内容分类添加-完成_

13.内容分类修改、删除-作业_

14.内容添加-功能分析_

15.内容添加-service_

16.内容添加-完成_

17.内容编辑、删除_

01.课程计划

(Redis缓存穿透和雪崩(首页并发量最高,每次都查询数据库压力比较大,通过缓存读取内存数据减轻数据库压力,Reids可以把内容持久化到磁盘数据不会丢,内容不会丢失否则瞬时请求会造成数据库雪崩,Redis缓存同步问题)&)

02.首页大广告位实现分析_

04.首页大广告位实现-表现层_

05.首页大广告-测试_

06.redis的安装及启动_

(gcc的简易用法(编译、参数与连接)(编译环境对c语言编译后为可二进制可执行文件,需要按照gcc编译环境,yum install gcc-c++)&用make进行宏编译&makefile的基本语法与变量&RPM安装(install)&Redis安装和配置(rm -rf * 删除所有安装包 ,rm -rf /user/local/redis* )&Redis客户端命令(tar zxf redis-3.0.0.tar.gz 进行解压缩,C语言编译必须有Makefile文件夹,直接使用make命令编译,编译后进行通过make install进行安装 make install PREFIX=/usr/local/redis到指定目录,进入安装目录的bin文件夹,通过./redis-server启动前端启动模式占用一个终端,通过配置文件cp ~/redis-3.0.0/redis.conf 复制到当前文件夹下,进行后端启动不占端口号,修改daemonize yes即可,通过./redis-server redis.conf 后端启动,通过ps aux|grep redis查看进程判断是否启动。 ./redis-cli默认连接6379端口,客户端通过ping pang检测服务器健康状态,连接其他redis服务 ./redis-cli -h 192.168 -p 6379)&Redis基础配置文件&)

sftp是Secure File Transfer Protocol的缩写,安全文件传送协议。它类似于ftp, 但是它提供一种更为安全的网络的加密方法。

如何进行远程连接,进行文件的上传和下载。

在命令行模式下,输入:

sftp 用户名@ip地址  eg: sftp lzy@202.206.64.33

sftp>

如果登陆远程机器不是为了上传下载文件,而是要修改远程主机上的某些文件。可以

ssh  lzy@202.206.64.33 (其实sftp就是ssh 的一个程式。)

sftp> get /var/index.php  /home/libai/

这条语句将从远程主机的  /var目录下将 index.php 下载到本地  /home/libai/目录下。
     sftp> put /home/libai/downloads/linuxgl.pdf  /var/
     这条语句将把本地 /home/libai/downloads/目录下的 linuxgl.pdf文件上传至远程主机/var 目录下。

要查看远端机器的一些信息,可以直接使用平时的linux命令

比如:pwd 远端机器的当前路径  cd 改变远端机器的路径 ,ls, rm, mkdir,rmdir 都可以用

要查看本机的一些信息,要在平时的linux命令上,加上l

比如:lpwd 本机当前工作目录  lcd 改变本机的路径, lls ,lrm,lmkdir,lrmdir

要离开sftp,用exit 或quit、 bye 均可。详细情况可以查阅 man  sftp.

如果觉得在命令行模式下不太方便,可以 sudo apt-get install gftp。在图形界面下操作就简便多了。

07.redis常用命令复_

(Redis数据结构常用命令(Redis一共提供5种数据类型,String普通key-value Hash一个key对应一个hash集,LIST集合 set集合 zset有序集合。String数据类型 set添加一个值 set str1 12345 get str1 incr str1自增,decr减1,Hash命令hset添加一个key hset hash1 field1 abc hget hash1 field1,ttl str1查看key的有效期-1永久保存,ttl str2 -2key不存在,正数正在倒计时,expire str1 100设置过期时间为100秒,key *查看数据库有多少key)&Redis数据结构——哈希&Redis数据结构——链表(linked-list)&Redis数据结构——集合&Redis数据结构——有序集合&INCRBY、DECRBY:对整数值执行加法操作和减法操作& HSET:为字段设置值&)

08.Jedis的使用方法_

(使用Jedis客户端操作Redis(Java客户端通过Jedis,每次创建都有一个连接耗费资源,通过redis连接池JedisPool 节约资源,jedis.getResource()获取jedis来操作数据库)&)

09.redis的使用方法_

(单线程与多线程客户端(持久化RDB和AOF默认开启RDB快照(当前时刻数据)定期操作磁盘,AOF保存对数据库操作的命令频繁操作磁盘性能下降,数据完整性高一点,可以同时开启。Redis有可能丢数据,Mysql或者Oracle关系型数据库不会丢数据,Redis不适合保存大数据适合存储小数据(单线程的顺次处理单个命令尽快完成,通过集群横向扩容),基于Hadoop的Hbase还有MongoDB支持存储海量数据)&)

10.redis集群架构讲解_

(使用Redis集群实现数据水平化存储(Redis集群没有统一的入口,可以连接任何客户端进入集群,集群内部客户端可以相互通讯,检测检点的监控状态通过投票容错实现,redis集群有0-16383个slot为了均匀分布key到不同服务器,每个节点分配一定数量的槽,一般集群分布在3个节点上,每个集群主从同步槽挂了包装高可用,需要6台服务器(一台服务器运行在不同端口6个实例,搭建集群要把dump.rdb快照文件删除,修改redis.conf改变端口号,/cluster-enabled yes集群节点。通过批处理批量执行启动命令 vim start-all.sh cd redis01 ./redis-server redis.conf) cd.. 通过chmod +x start-all.sh增加可执行权限,TCC最大权限 ,./start-all.sh执行)&对文章进行投票&Redis集群容错&Redis集群中的主从复制&Redis主从复制模式&)

11.redis集群搭建01_

(Redis主从架构的缺点&Redis哨兵模式& Redis集群架构& Redis集群环境搭建&mongodump 和mongorestore&批处理和任务&权限设置&)

12.redis集群搭建02_

(RPM、SRPM与YUM&)

13.使用redis-cli连接集群_

14.使用JedisCluster连接集群_

(使用Jedis客户端操作Redis(Java通过JedisCluster连接到集群,自带连接池,构造参数是set类型集合每个元素是HostAndPort类型)&)

15.JedisClient连接单机版_

(使用Annotation注解法创建对象(<context:component-scan base-package=””>注解既包括了开启注解<context:annotation-config>也包括了扫描包)&组件扫描注解&)

16.jedisClient连接集群_

17.向业务逻辑中添加缓存_

18.添加缓存测试_

19.缓存同步处理_

(消息发送和同步接收&HDEL:删除字段&)

day06

01.课程计划_

02.solr服务搭建_

(catalina.sh脚本&Redis基础配置文件&Tomcat启动&复制、删除与移动:cp、rm、mv &配置web.xml文件&)

03.业务域的定义_

(中文分词安装&IK分词器安装&内部类——InnerClasses属性 &基于XML Schema的简化配置方式&使用th:field属性&语言区域&使用服务提供业务逻辑&)

04.业务数据sql语句编写_

05.搜索工程搭建_

(覆盖起步依赖引入的传递依赖&)

06.导入商品数据到索引库-dao_

07.solrj实现索引库维护_

(在Sping Boot中集成Solr,实现数据的增、删、改和查&)

08.导入商品数据-Service_

( constructor方法&)

09.导入商品数据-jsp_

10.商品数据导入成功_

11.首页跳转到搜索页面_

12.商品实现分析_

13.使用solrJ查询索引库_

(Solr——搜索应用服务器&)

14.搜索服务-dao实现_

day07

01.课程计划_

02.商品搜索功能-Service_

03.商品搜索功能-Controller_

04.搜索功能测试_

05.什么是SolrCloud_

06.solr集群架构讲解_

(并发&分片简介&)

07.zookeeper集群讲解_

08.zookeeper集群搭建_

(配置ZooKeeper集群&Data Server简介&修改文件时间或创建新文件:touch&变量的使用与设置:echo、变量设置规则、unset &vim的额外功能&)

09.solr集群的配置_

10.SolrCloud中管理Collection_

11.闲扯_

12.使用SolrJ管理SolrCloud_

13.搜索功能切换到集群_

14.全局异常处理器的应用_

day08

01.课程计划_

02.同步索引库功能分析_

03.什么是ActiveMQ_

04.activemq的安装_

(vim的额外功能&)

05.Activemq发送queue消息_

(Topic 和 Queue&)

06.接收queue消息_

07.发送topic消息_

08.接收topic消息_

09.spring整合Activemq_

(使用JmsTemplate 发送&)

10.使用JMSTemplate发送消息_

11.Activemq整合Spring接收消息_

12.添加商品同步索引库-发送消息_

13.添加商品同步索引库-mapper_

14.添加商品同步索引库-MessageListener_

15.添加商品同步索引库-测试_

16.小结_

day09

01.课程计划_

02.商品详情页面工程搭建_

03.商品详情页面展示分析_

04.商品详情页面展示-代码实现_

05.商品详情页面展示-测试_

06.商品详情页面添加缓存分析_

07.redis添加缓存的使用方法_

08.向业务逻辑中添加缓存_

09.添加缓存测试_

10.freemarker的使用方法_

11.freemarker语法-取pojo的属性_

12.freemarker语法-list_

13.freemarker语法-if_

14.freemarker语法-日期类型处理_

15freemarker语法-null值的处理_

16.freemarker语法-include_

17.freemarker整合Spring_

18.网页静态化方案分析_

19.网页静态化-freemarker模板改造_

20.网页静态化-业务逻辑_

21.网页静态化-测试_

day10

01.课程计划_

(构建HTTP服务器&)

02.什么是nginx_

03.nginx的应用场景_

04.nginx的安装及启动_

( v-pre&)

05.nginx的配置文件介绍_

06.通过端口区分虚拟主机_

(shift&使用fetchType属性设置局部加载策略&ngx_http_upstream_t结构体&)

07.什么是域名及hosts文件的作用_

08.通过域名区分虚拟主机_

09.使用nginx配置反向代理_

(proxy_pass请求代理规则&)

10.使用nginx实现负载均衡_

11.nginx小结_

12.keepalived+nginx实现高可用_

13.lvs实现高并发处理_

14.sso系统分析_

15.sso工程搭建_

16.sso系统接口分析_

day11_单点登录&js跨域

01.课程计划_

02.检查数据是否可用-接口分析_

03.检查数据是否可用-Service_

04.检查数据是否可用-Controller_

05.用户注册-Service_

06.用户注册-表现层_

07.用户登录流程分析_

08.用户登录-Service_

(使用Redis保存token令牌&全局唯一标识符UUID&)

09.用户登录表现层_

10.用户登录测试_

11.根据token查询用户信息-Service_

(使用Redis保存token令牌&)

12.根据token查询用户信息-表现层层_

13.安全退出-作业_

14.登录、注册页面展示_

15.用户注册页面实现_

16.用户登页面实现_

17.js跨域分析_

(跨域AJAX&)

  1. jsonp的原理_

(活用模板方法模式及Callback&callback调用&JSONP&media query语法&)

19.jsonp服务端处理_

20.jsonp处理第二种方法_

day12

01.课程计划_

02.购物车实现分析_

03.购物车工程搭建_

04.商品详情页面加入购物车改造_

05.添加购物车功能分析_

06.添加购物车实现_

07.添加购物车测试_

08.展示购物车列表_

09.修改购物车商品数量_

10.修改购物车商品数量测试_

11.删除购物车商品_

12.购物车小结_

13.订单系统工程搭建_

14.订单确认页面展示_

15.登录拦截器实现分析_

(HandlerInterceptor接口&Handler实例&)

16.拦截器业务逻辑实现_

17.拦截器测试及登录成功回调_

(Interceptor&)

18.拦截器测试取用户信息_

19.订单生成-数据库分析_

20.订单生成-页面分析_

day13

01.课程计划_

02.订单提交-分析回顾_

03.生成订单业务逻辑_

04.订单生成表现层_

05.订单生成-测试_

06.系统架构讲解_

07.系统部署规划_

(安装RPM包&)

08.tomcat热部署_

09.系统部署演示_

10.项目总结01_

11.项目总结02_

12.面试中的问题_

部分代码

taotao-sso-web

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.taotao</groupId><artifactId>taotao-parent</artifactId><version>0.0.1-SNAPSHOT</version></parent><groupId>com.taotao</groupId><artifactId>taotao-sso-web</artifactId><version>0.0.1-SNAPSHOT</version><packaging>war</packaging><dependencies><dependency><groupId>com.taotao</groupId><artifactId>taotao-common</artifactId><version>0.0.1-SNAPSHOT</version></dependency><dependency><groupId>com.taotao</groupId><artifactId>taotao-sso-interface</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!-- Spring --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jms</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId></dependency><!-- JSP相关 --><dependency><groupId>jstl</groupId><artifactId>jstl</artifactId></dependency><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><scope>provided</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jsp-api</artifactId><scope>provided</scope></dependency><!-- dubbo相关的jar包 --><dependency><groupId>com.alibaba</groupId><artifactId>dubbo</artifactId><exclusions><exclusion><artifactId>spring</artifactId><groupId>org.springframework</groupId></exclusion><exclusion><artifactId>netty</artifactId><groupId>org.jboss.netty</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.zookeeper</groupId><artifactId>zookeeper</artifactId></dependency><dependency><groupId>com.github.sgroschupf</groupId><artifactId>zkclient</artifactId></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><configuration><path>/</path><port>8088</port></configuration></plugin></plugins></build>
</project>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID" version="2.5"><display-name>taotao-sso-web</display-name><welcome-file-list><welcome-file>index.html</welcome-file></welcome-file-list><!-- post乱码过滤器 --><filter><filter-name>CharacterEncodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>utf-8</param-value></init-param></filter><filter-mapping><filter-name>CharacterEncodingFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><!-- 前端控制器 --><servlet><servlet-name>taotao-sso-web</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><!-- contextConfigLocation不是必须的, 如果不配置contextConfigLocation, springmvc的配置文件默认在:WEB-INF/servlet的name+"-servlet.xml" --><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring/springmvc*.xml</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>taotao-sso-web</servlet-name><url-pattern>/</url-pattern></servlet-mapping></web-app>

register.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache,must-revalidate"><title>注册-个人用户</title><link type="text/css" rel="stylesheet" href="/css/regist.personal.css"/><link type="text/css" rel="stylesheet" href="/css/passport.base.css"/><script type="text/javascript" src="/js/jquery-1.6.4.js"></script>
</head>
<body>
<div class="w" id="logo"><div><a href="http://localhost:8082"><img src="/images/taotao-logo.gif" alt="淘淘商城" width="170" height="60"/></a> <b></b></div>
</div><div class="w" id="regist"><div class="mt"><ul class="tab"><li class="curr">个人用户</li></ul><div class="extra"><span>我已经注册,现在就&nbsp;<a href="http://localhost:8088/page/login" class="flk13">登录</a></span></div></div><div class="mc"><form id="personRegForm" method="post" onsubmit="return false;"><div class="form" onselectstart="return false;"><div class="item" id="select-regName"><span class="label"><b class="ftx04">*</b>用户名:</span><div class="fl item-ifo"><div class="o-intelligent-regName"><input type="text" id="regName" name="username" class="text" tabindex="1" autoComplete="off"onpaste="return false;"value=""onfocus="if(this.value=='') this.value='';this.style.color='#333'"onblur="if(this.value=='') {this.value='';this.style.color='#999999'}"/><i class="i-name"></i><ul id="intelligent-regName" class="hide"></ul><label id="regName_succeed" class="blank"></label><label id="regName_error" class="hide"></label></div></div></div><div id="o-password"><div class="item"><span class="label"><b class="ftx04">*</b>请设置密码:</span><div class="fl item-ifo"><input type="password" id="pwd" name="password" class="text" tabindex="2"style="ime-mode:disabled;"onpaste="return  false" autocomplete="off"/><i class="i-pass"></i><label id="pwd_succeed" class="blank"></label><label id="pwd_error"></label><span class="clr"></span></div></div><div class="item"><span class="label"><b class="ftx04">*</b>请确认密码:</span><div class="fl item-ifo"><input type="password" id="pwdRepeat" name="pwdRepeat" class="text" tabindex="3"onpaste="return  false" autocomplete="off"/><i class="i-pass"></i><label id="pwdRepeat_succeed" class="blank"></label><label id="pwdRepeat_error"></label></div></div><div class="item" id="dphone"><span class="label"><b class="ftx04">*</b>验证手机:</span><div class="fl item-ifo"><input type="text" id="phone" maxlength="11" name="phone"class="text" tabindex="4"autocomplete="off" /> <i class="i-phone"></i> <labelid="phone_succeed" class="blank"></label> <labelid="phone_error"></label></div></div></div><div class="item item-new"><span class="label">&nbsp;</span><div class="fl item-ifo"><input type="checkbox" class="checkbox" checked="checked" id="readme"onclick="agreeonProtocol();"><label for="protocol">我已阅读并同意<a href="#" class="blue" id="protocol">《淘淘用户注册协议》</a></label><span class="clr"></span><label id="protocol_error" class="error hide">请接受服务条款</label></div></div><div class="item"><span class="label">&nbsp;</span><input type="button" class="btn-img btn-regist" id="registsubmit" value="立即注册" tabindex="8"clstag="regist|keycount|personalreg|07"onclick="REGISTER.reg();"/></div></div><div class="phone"><img width="180" height="180" src="/images/phone-bg.jpg"></div><span class="clr"></span></form></div>
<script type="text/javascript">var REGISTER={param:{//单点登录系统的urlsurl:""},inputcheck:function(){//不能为空检查if ($("#regName").val() == "") {alert("用户名不能为空");$("#regName").focus();return false;}if ($("#pwd").val() == "") {alert("密码不能为空");$("#pwd").focus();return false;}if ($("#phone").val() == "") {alert("手机号不能为空");$("#phone").focus();return false;}//密码检查if ($("#pwd").val() != $("#pwdRepeat").val()) {alert("确认密码和密码不一致,请重新输入!");$("#pwdRepeat").select();$("#pwdRepeat").focus();return false;}return true;},beforeSubmit:function() {//检查用户是否已经被占用$.ajax({url : REGISTER.param.surl + "/user/check/"+escape($("#regName").val())+"/1?r=" + Math.random(),success : function(data) {if (data.data) {//检查手机号是否存在$.ajax({url : REGISTER.param.surl + "/user/check/"+$("#phone").val()+"/2?r=" + Math.random(),success : function(data) {if (data.data) {REGISTER.doSubmit();} else {alert("此手机号已经被注册!");$("#phone").select();}}});} else {alert("此用户名已经被占用,请选择其他用户名");$("#regName").select();}    }});},doSubmit:function() {$.post("/user/register",$("#personRegForm").serialize(), function(data){if(data.status == 200){alert('用户注册成功,请登录!');REGISTER.login();} else {alert("注册失败!");}});},login:function() {location.href = "/page/login";return false;},reg:function() {if (this.inputcheck()) {this.beforeSubmit();}}};
</script>
</body>
</html>

login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"/><title>登录淘淘</title><link type="text/css" rel="stylesheet" href="/css/login.css"/><script type="text/javascript" src="/js/jquery-1.6.4.js"></script>
</head>
<body>
<div class="w"><div id="logo"><a href="http://localhost:8082" clstag="passport|keycount|login|01"><img src="/images/taotao-logo.gif" alt="淘淘" width="170" height="60"/></a><b></b></div>
</div>
<form id="formlogin" method="post" onsubmit="return false;"><div class=" w1" id="entry"><div class="mc " id="bgDiv"><div id="entry-bg" clstag="passport|keycount|login|02" style="width: 511px; height: 455px; position: absolute; left: -44px; top: -44px; background: url(/images/544a11d3Na5a3d566.png) 0px 0px no-repeat;"></div><div class="form "><div class="item fore1"><span>用户名</span><div class="item-ifo"><input type="text" id="loginname" name="username" class="text"  tabindex="1" autocomplete="off"/><div class="i-name ico"></div><label id="loginname_succeed" class="blank invisible"></label><label id="loginname_error" class="hide"><b></b></label></div></div><script type="text/javascript">setTimeout(function () {if (!$("#loginname").val()) {$("#loginname").get(0).focus();}}, 0);</script><div id="capslock"><i></i><s></s>键盘大写锁定已打开,请注意大小写</div><div class="item fore2"><span>密码</span><div class="item-ifo"><input type="password" id="nloginpwd" name="password" class="text" tabindex="2" autocomplete="off"/><div class="i-pass ico"></div><label id="loginpwd_succeed" class="blank invisible"></label><label id="loginpwd_error" class="hide"></label></div></div><div class="item login-btn2013"><input type="button" class="btn-img btn-entry" id="loginsubmit" value="登录" tabindex="8" clstag="passport|keycount|login|06"/></div></div></div><div class="free-regist"><span><a href="/user/showRegister" clstag="passport|keycount|login|08">免费注册&gt;&gt;</a></span></div></div>
</form>
<script type="text/javascript">var redirectUrl = "${redirect}";var LOGIN = {checkInput:function() {if ($("#loginname").val() == "") {alert("用户名不能为空");$("#loginname").focus();return false;}if ($("#nloginpwd").val() == "") {alert("密码不能为空");$("#nloginpwd").focus();return false;}return true;},doLogin:function() {$.post("/user/login", $("#formlogin").serialize(),function(data){if (data.status == 200) {alert("登录成功!");if (redirectUrl == "") {location.href = "http://localhost:8082";} else {location.href = redirectUrl;}} else {alert("登录失败,原因是:" + data.msg);$("#loginname").select();}});},login:function() {if (this.checkInput()) {this.doLogin();}}};$(function(){$("#loginsubmit").click(function(){LOGIN.login();});});
</script>
</body>
</html>

exception.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport"content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>出错了 -淘淘商城</title>
<!--结算页面样式-->
<link rel="stylesheet" type="text/css" href="/css/base.css" media="all" />
<link type="text/css" rel="stylesheet" href="/css/order-commons.css"source="widget" />
<script type="text/javascript" src="/js/jquery-1.6.4.js"></script>
<script type="text/javascript" src="/js/base.js"></script>
<script type="text/javascript" src="/js/order.common.js"></script>
<script type="text/javascript" src="/js/jquery.checkout.js"></script>
</head>
<body id="mainframe"><div class="w w1 header clearfix"><div id="logo"><a href="/"><img src="/images/taotao-logo.gif" alt="淘淘商城"></a></div></div><div class="w"><div id="refresh"><style type="text/css">
#refresh {text-align: left;margin: 30px auto;width: 750px;height: 220px;background:url(/images/errordog.jpg)0 0;position: relative
}#refresh .txt {position: absolute;left: 236px;top: 16px;color: #fff;font-size: 14px;font-family: "microsoft yahei"
}#refresh .m {position: absolute;left: 336px;top: 80px;line-height: 18px;font-size: 14px
}#refresh .m li {padding-bottom: 8px
}#refresh .m a {color: #005eab
}#refresh .m .fore1, #refresh .m .fore2 {font-family: "microsoft yahei"
}#refresh .m .fore1 a {color: #e4393c
}#refresh .m .fore2 a {color: #e4393c;font-weight: bold;font-size: 18px;padding: 0 3px
}#refresh .m .fore3 {font-weight: bold;font-size: 12px
}#refresh .m .fore4 a {margin-right: 15px;font-size: 12px
}</style><span class="txt">糟了...系统出错了...</span><ul class="m"><li class="fore1">您可以:稍后再试或联系客服400-8888-9999。</li><li class="fore2">返回<a href="/" target="_blank">淘淘首页</a></li><li class="fore3">错误消息</li><li class="fore4">${message }</li></ul></div></div><!-- footer start --><jsp:include page="../commons/footer.jsp" /><!-- footer end -->
</body>
</html>

shortcut.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div id="shortcut-2013"><div class="w"><ul class="fl lh"><li class="fore1 ld" clstag="homepage|keycount|home2013|01a"><b></b><a href="javascript:addToFavorite()" rel="nofollow">收藏淘淘</a></li></ul><ul class="fr lh"><li class="fore1" id="loginbar" clstag="homepage|keycount|home2013|01b">您好!欢迎来到淘淘!<a href="javascript:login()">[登录]</a>&nbsp;<a href="javascript:regist()">[免费注册]</a></li><li class="fore2 ld" clstag="homepage|keycount|home2013|01c"><s></s><a href="http://jd2008.jd.com/JdHome/OrderList.aspx" rel="nofollow">我的订单</a></li><li class="fore2-1 ld" id="jd-vip"><s></s><a target="_blank" rel="nofollow" href="http://vip.jd.com">会员俱乐部</a></li><li class="fore3 ld menu" id="app-jd" data-widget="dropdown" clstag="homepage|keycount|home2013|01d"><s></s><i></i><span class="outline"></span><span class="blank"></span><a href="http://app.jd.com/" target="_blank">手机淘淘</a><b></b></li><li class="fore4 ld menu" id="biz-service" data-widget="dropdown" clstag="homepage|keycount|home2013|01e"><s></s><span class="outline"></span><span class="blank"></span>客户服务<b></b><div class="dd"><div><a href="http://help.jd.com/index.html" target="_blank">帮助中心</a></div><div><a href="http://myjd.jd.com/repair/orderlist.action" target="_blank" rel="nofollow">售后服务</a></div><div><a href="http://chat.jd.com/jdchat/custom.action" target="_blank" rel="nofollow">在线客服</a></div><div><a href="http://myjd.jd.com/opinion/list.action" target="_blank" rel="nofollow">投诉中心</a></div><div><a href="http://www.jd.com/contact/service.html" target="_blank">客服邮箱</a></div></div></li><li class="fore5 ld menu" id="site-nav" data-widget="dropdown" clstag="homepage|keycount|home2013|01f"><s></s><span class="outline"></span><span class="blank"></span>网站导航<b></b><div class="dd lh"><dl class="item fore1"><dt>特色栏目</dt><dd><div><a target="_blank" href="http://mobile.jd.com/index.do">淘淘通信</a></div><div><a target="_blank" href="http://jdstar.jd.com/">校园之星</a></div><div><a target="_blank" href="http://my.jd.com/personal/guess.html">为我推荐</a></div><div><a target="_blank" href="http://shipingou.jd.com/">视频购物</a></div><div><a target="_blank" href="http://club.jd.com/">淘淘社区</a></div><div><a target="_blank" href="http://read.jd.com/">在线读书</a></div><div><a target="_blank" href="http://diy.jd.com/">装机大师</a></div><div><a target="_blank" href="http://giftcard.jd.com/market/index.action">淘淘E卡</a></div><div><a target="_blank" href="http://channel.jd.com/jiazhuang.html">家装城</a></div><div><a target="_blank" href="http://dapeigou.jd.com/">搭配购</a></div><div><a target="_blank" href="http://xihuan.jd.com/">我喜欢</a></div></dd></dl><dl class="item fore2"><dt>企业服务</dt><dd><div><a target="_blank" href="http://giftcard.jd.com/company/index">企业客户</a></div><div><a target="_blank" href="http://sale.jd.com/p10997.html">办公直通车</a></div></dd></dl><dl class="item fore3"><dt>旗下网站</dt><dd><div><a target="_blank" href="http://en.jd.com/">English Site</a></div></dd></dl></div></li></ul><span class="clr"></span></div>
</div>

header.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<script type="text/javascript" src="/js/base-v1.js" charset="utf-8"></script>
<!--shortcut start-->
<jsp:include page="shortcut.jsp" />
<!--shortcut end-->
<div id="o-header-2013"><div class="w" id="header-2013"><div id="logo-2013" class="ld"><a href="/" hidefocus="true" clstag="homepage|keycount|home2013|02a"><b></b><img src="/images/taotao-logo.gif" width="270" height="60" alt="淘淘"></a></div><!--logo end--><div id="search-2013"><div class="i-search ld"><ul id="shelper" class="hide"></ul><div class="form"><input type="text" class="text" accesskey="s" id="key" autocomplete="off" onkeydown="javascript:if(event.keyCode==13) search('key');"><input type="button" value="搜索" class="button" onclick="search('key');return false;" clstag="homepage|keycount|home2013|03a"></div></div><div id="hotwords" clstag="homepage|keycount|home2013|03b"></div></div><!--search end--><div id="my360buy-2013"><dl><dt class="ld"><s></s><a href="http://localhost:8084/user/showLogin" clstag="homepage|keycount|home2012|04a">我的淘淘</a><b></b></dt><dd><div class="loading-style1"><b></b>加载中,请稍候...</div></dd></dl></div><!--my360buy end--><div id="settleup-2013" clstag="homepage|keycount|home2013|05a"><dl><dt class="ld"><s></s><span class="shopping"><span id="shopping-amount"></span></span><a href="/cart/cart.html" id="settleup-url">去购物车结算</a> <b></b> </dt>
<!--                 <dd><div class="prompt"><div class="loading-style1"><b></b>加载中,请稍候...</div></div></dd>-->           </dl></div><!--settleup end--></div><!--header end--><div class="w"><div id="nav-2013"><div id="categorys-2013" class="categorys-2014"><div class="mt ld"><h2><a href="http://www.jd.com/allSort.aspx" clstag="homepage|keycount|home2013|06a">全部商品分类<b></b></a></h2></div><div id="_JD_ALLSORT" class="mc"><div class="item fore1"><span data-split="1"><h3><a href="/products/1.html">图书、音像、电子书刊</a></h3><s></s></span></div><div class="item fore2"><span data-split="1"><h3><a href="/products/74.html">家用电器</a></h3><s></s></span></div><div class="item fore3"><span data-split="1"><h3><a href="/products/161.html">电脑、办公</a></h3><s></s></span></div><div class="item fore4"><span data-split="1"><h3><a href="/products/249.html">个护化妆</a></h3><s></s></span></div><div class="item fore5"><span data-split="1"><h3><a href="/products/290.html">钟表</a></h3><s></s></span></div><div class="item fore6"><span data-split="1"><h3><a href="/products/296.html">母婴</a></h3><s></s></span></div><div class="item fore7"><span data-split="1"><h3><a href="/products/378.html">食品饮料、保健食品</a></h3><s></s></span></div><div class="item fore8"><span data-split="1"><h3><a href="/products/438.html">汽车用品</a></h3><s></s></span></div><div class="item fore9"><span data-split="1"><h3><a href="/products/495.html">玩具乐器</a></h3><s></s></span></div><div class="item fore10"><span data-split="1"><h3><a href="/products/558.html">手机</a></h3><s></s></span></div><div class="item fore11"><span data-split="1"><h3><a href="/products/580.html">数码</a></h3><s></s></span></div><div class="item fore12"><span data-split="1"><h3><a href="/products/633.html">家居家装</a></h3><s></s></span></div><div class="item fore13"><span data-split="1"><h3><a href="/products/699.html">厨具</a></h3><s></s></span></div><div class="item fore14"><span data-split="1"><h3><a href="/products/749.html">服饰内衣</a></h3><s></s></span></div><div class="extra"><a {if="" pageconfig.ishome}clstag="homepage|keycount|home2013|0614a"{="" if}="" href="http://www.jd.com/allSort.aspx">全部商品分类</a></div></div></div><div id="treasure" clstag="homepage|keycount|home2013|08a"></div><ul id="navitems-2013"><li class="fore1" id="nav-home" clstag="homepage|keycount|home2013|07a"><a href="/">首页</a></li><li class="fore2" id="nav-fashion" clstag="homepage|keycount|home2013|07b"><a href="http://fashion.jd.com/">服装城</a></li><li class="fore3" id="nav-chaoshi" clstag="homepage|keycount|home2013|07c"><a href="http://channel.jd.com/chaoshi.html">食品</a></li><li class="fore4" id="nav-tuan" clstag="homepage|keycount|home2013|07d"><a href="http://tuan.jd.com/" target="_blank">团购</a></li><li class="fore5" id="nav-auction" clstag="homepage|keycount|home2013|07e"><a href="http://auction.jd.com/">夺宝岛</a></li><li class="fore6" id="nav-shan" clstag="homepage|keycount|home2013|07f"><a href="http://red.jd.com/" target="_blank">闪购</a></li><li class="fore7" id="nav-jinrong" clstag="homepage|keycount|home2013|07g1"><a href="http://jr.jd.com/" target="_blank">金融</a></li></ul></div></div>
</div>
<script type="text/javascript">
(function(){if(pageConfig.navId){var object=document.getElementById("nav-"+pageConfig.navId);if(object)object.className+=" curr";}})();
</script>

footer-links.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<div id="footer-2013"><div class="links"><a href="http://www.jd.com/intro/about.aspx" target="_blank" rel="nofollow">关于我们</a>|<a href="http://www.jd.com/contact/" target="_blank" rel="nofollow">联系我们</a>|<a href="http://zhaopin.jd.com/" target="_blank" rel="nofollow">人才招聘</a>|<a href="http://www.jd.com/contact/joinin.aspx" target="_blank" rel="nofollow">商家入驻</a>|<a href="http://jzt.jd.com" target="_blank" rel="nofollow">营销中心</a>|<a href="http://app.jd.com/" target="_blank" rel="nofollow">手机淘淘</a>|<a href="http://club.jd.com/links.aspx" target="_blank">友情链接</a>|<a href="http://media.jd.com/" target="_blank">销售联盟</a>|<a target="_blank" href="http://club.jd.com/">淘淘社区</a>|<a target="_blank" href="http://gongyi.jd.com">淘淘公益</a>|<a target="_blank" href="http://en.jd.com/">English Site</a></div>
</div>

footer.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<div class="w" clstag="homepage|keycount|home2013|37a"><div id="service-2013"><dl class="fore1"><dt><b></b><strong>购物指南</strong></dt><dd><div><a href="http://help.jd.com/help/question-56.html" target="_blank" rel="nofollow">购物流程</a></div><div><a href="http://help.jd.com/help/question-57.html" target="_blank" rel="nofollow">会员介绍</a></div><div><a href="http://help.jd.com/help/question-181.html" target="_blank" rel="nofollow">团购/机票</a></div><div><a href="http://help.jd.com/help/question-61.html" target="_blank" rel="nofollow">常见问题</a></div><div><a href="http://help.jd.com/help/question-63.html" target="_blank" rel="nofollow">大家电</a></div><div><a href="http://help.jd.com/index.html" target="_blank" rel="nofollow">联系客服</a></div></dd></dl><dl class="fore2">        <dt><b></b><strong>配送方式</strong></dt><dd><div><a href="http://help.jd.com/help/question-64.html" target="_blank" rel="nofollow">上门自提</a></div><div><a href="http://help.jd.com/help/question-360.html" target="_blank" rel="nofollow">211限时达</a></div><div><a href="http://help.jd.com/help/distribution-768.html" target="_blank" rel="nofollow">配送服务查询</a></div><div><a href="http://help.jd.com/help/question-892.html#help2215" target="_blank" rel="nofollow">配送费收取标准</a></div><div><a href="http://market.jd.com/giftcard/index.html#one5" target="_blank" rel="nofollow">如何送礼</a></div><div><a href="http://en.jd.com/chinese.html" target="_blank">海外配送</a></div></dd></dl><dl class="fore3"><dt><b></b><strong>支付方式</strong></dt><dd><div><a href="http://help.jd.com/help/question-67.html" target="_blank" rel="nofollow">货到付款</a></div><div><a href="http://help.jd.com/help/question-68.html" target="_blank" rel="nofollow">在线支付</a></div><div><a href="http://help.jd.com/help/question-71.html" target="_blank" rel="nofollow">分期付款</a></div><div><a href="http://help.jd.com/help/question-69.html" target="_blank" rel="nofollow">邮局汇款</a></div><div><a href="http://help.jd.com/help/question-70.html" target="_blank" rel="nofollow">公司转账</a></div></dd></dl><dl class="fore4">       <dt><b></b><strong>售后服务</strong></dt><dd><div><a href="http://myjd.jd.com/afs/help/afshelp.action" target="_blank" rel="nofollow">售后政策</a></div><div><a href="http://help.jd.com/help/question-99.html" target="_blank" rel="nofollow">价格保护</a></div><div><a href="http://help.jd.com/help/question-100.html" target="_blank" rel="nofollow">退款说明</a></div><div><a href="http://myjd.jd.com/repair/repairs.action" target="_blank" rel="nofollow">返修/退换货</a></div><div><a href="http://help.jd.com/help/question-881.html" target="_blank" rel="nofollow">取消订单</a></div></dd></dl><dl class="fore5"><dt><b></b><strong>特色服务</strong></dt><dd>     <div><a href="http://help.jd.com/help/question-79.html" target="_blank">夺宝岛</a></div><div><a href="http://help.jd.com/help/question-86.html" target="_blank">DIY装机</a></div><div><a href="http://fuwu.jd.com/" target="_blank" rel="nofollow">延保服务</a></div><div><a href="http://giftcard.jd.com/market/index.action" target="_blank" rel="nofollow">淘淘E卡</a></div><div><a href="http://help.jd.com/help/question-91.html" target="_blank" rel="nofollow">节能补贴</a></div><div><a href="http://mobile.jd.com/" target="_blank" rel="nofollow">淘淘通信</a></div></dd></dl><div class="fr"><div class="sm" id="branch-office"><div class="smt"><h3>淘淘自营覆盖区县</h3></div><div class="smc"><p>淘淘已向全国1859个区县提供自营配送服务,支持货到付款、POS机刷卡和售后上门服务。</p><p class="ar"><a href="http://help.jd.com/help/distribution-768.html" target="_blank">查看详情&nbsp;></a></p></div></div></div><span class="clr"></span></div>
</div>
<div class="w" clstag="homepage|keycount|home2013|38a"><jsp:include page="footer-links.jsp"></jsp:include>
</div>
<script type="text/javascript" src="/js/jquery-1.6.4.js"></script>
<script type="text/javascript" src="/js/jquery-extend.js"></script>
<script type="text/javascript" src="/js/lib-v1.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/taotao.js" charset="utf-8"></script>
<script type="text/javascript"> (function(){
var A="<strong>热门搜索:</strong><a href='http://sale.jd.com/act/OfHQzJ2GLoYlmTIu.html' target='_blank' style='color:#ff0000' clstag='homepage|keycount|home2013|03b1'>校园之星</a><a href='http://sale.jd.com/act/aEBHqLFMfVzDZUvu.html' target='_blank'>办公打印</a><a href='http://www.jd.com/pinpai/878-12516.html' target='_blank'>美菱冰箱</a><a href='http://sale.jd.com/act/nuzKb6ZiYL.html' target='_blank'>无肉不欢</a><a href='http://sale.jd.com/act/ESvhtcAJNbaj.html' target='_blank'>万件好货</a><a href='http://sale.jd.com/act/nAqiWgU34frQolt.html' target='_blank'>iPhone6</a><a href='http://sale.jd.com/act/p0CmUlEFPHLX.html' target='_blank'>哈利波特</a><a href='http://sale.jd.com/act/FstSdb2vCOLa8BRi.html' target='_blank'>美模接驾</a>";
var B=["java","apple","LG G3","天梭","保温杯","三个爸爸"];
B=pageConfig.FN_GetRandomData(B);
$("#hotwords").html(A);
var _searchValue = "${query}";
if(_searchValue.length == 0){_searchValue = B;
}
$("#key").val(_searchValue).bind("focus",function(){if (this.value==B){this.value="";this.style.color="#333"}}).bind("blur",function(){if (!this.value){this.value=B;this.style.color="#999"}});
})();
</script>

taotao.js

var TT = TAOTAO = {checkLogin : function(){var _ticket = $.cookie("TT_TOKEN");if(!_ticket){return ;}$.ajax({url : "http://localhost:8084/user/token/" + _ticket,dataType : "jsonp",type : "GET",success : function(data){if(data.status == 200){var username = data.data.username;var html = username + ",欢迎来到淘淘!<a href=\"http://www.taotao.com/user/logout.html\" class=\"link-logout\">[退出]</a>";$("#loginbar").html(html);}}});}
}$(function(){// 查看是否已经登录,如果已经登录查询登录信息TT.checkLogin();
});

springmvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsdhttp://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"><!-- 加载属性文件 --><context:property-placeholder location="classpath:resource/resource.properties"/><!-- 配置注解驱动 --><mvc:annotation-driven /><!-- 视图解析器 --><beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/jsp/" /><property name="suffix" value=".jsp" /></bean><!-- 配置包扫描器,扫描@Controller注解的类 --><context:component-scan base-package="com.taotao.sso.controller"/><!-- 配置资源映射 --><mvc:resources location="/WEB-INF/css/" mapping="/css/**"/><mvc:resources location="/WEB-INF/js/" mapping="/js/**"/><mvc:resources location="/WEB-INF/images/" mapping="/images/**"/><!-- 引用dubbo服务 --><dubbo:application name="taotao-sso-web"/><dubbo:registry protocol="zookeeper" address="192.168.25.167:2181"/> <dubbo:reference interface="com.taotao.sso.service.UserService" id="userService" />
</beans>      

resource.properties

#cookie\u4e2d\u4fdd\u5b58token\u7684\u53ef\u4ee5
TOKEN_KEY=TT_TOKEN
package com.taotao.sso.controller;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;import com.taotao.common.pojo.TaotaoResult;
import com.taotao.common.utils.CookieUtils;
import com.taotao.common.utils.JsonUtils;
import com.taotao.pojo.TbUser;
import com.taotao.sso.service.UserService;/*** 用户处理Controller* <p>Title: UserController</p>* <p>Description: </p>* <p>Company: www.itcast.cn</p> * @version 1.0*/
@Controller
public class UserController {@Value("${TOKEN_KEY}")private String TOKEN_KEY;@Autowiredprivate UserService userService;@RequestMapping("/user/check/{param}/{type}")@ResponseBodypublic TaotaoResult checkUserData(@PathVariable String param, @PathVariable Integer type) {TaotaoResult result = userService.checkData(param, type);return result;}@RequestMapping(value="/user/register", method=RequestMethod.POST)@ResponseBodypublic TaotaoResult regitster(TbUser user) {TaotaoResult result = userService.register(user);return result;}@RequestMapping(value="/user/login", method=RequestMethod.POST)@ResponseBodypublic TaotaoResult login(String username, String password, HttpServletResponse response, HttpServletRequest request) {TaotaoResult result = userService.login(username, password);//登录成功后写cookieif (result.getStatus() == 200) {//把token写入cookieCookieUtils.setCookie(request, response, TOKEN_KEY, result.getData().toString());}return result;}/*@RequestMapping(value="/user/token/{token}", method=RequestMethod.GET, //指定返回响应数据的content-typeproduces=MediaType.APPLICATION_JSON_UTF8_VALUE)@ResponseBodypublic String getUserByToken(@PathVariable String token, String callback) {TaotaoResult result = userService.getUserByToken(token);//判断是否为jsonp请求if (StringUtils.isNotBlank(callback)) {return callback + "(" + JsonUtils.objectToJson(result) + ");";}return JsonUtils.objectToJson(result);}*///jsonp的第二种方法,spring4.1以上版本使用@RequestMapping(value="/user/token/{token}", method=RequestMethod.GET)@ResponseBodypublic Object getUserByToken(@PathVariable String token, String callback) {TaotaoResult result = userService.getUserByToken(token);//判断是否为jsonp请求if (StringUtils.isNotBlank(callback)) {MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(result);//设置回调方法mappingJacksonValue.setJsonpFunction(callback);return mappingJacksonValue;}return result;}}
package com.taotao.sso.controller;import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;/*** 展示登录和注册页面的Controller* <p>Title: PageController</p>* <p>Description: </p>* <p>Company: www.itcast.cn</p> * @version 1.0*/
@Controller
public class PageController {@RequestMapping("/page/register")public String showRegister() {return "register";}@RequestMapping("/page/login")public String showLogin(String url, Model model) {model.addAttribute("redirect", url);return "login";}
}

taotao-sso

pom.xml

taotao-sso-service

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.taotao</groupId><artifactId>taotao-sso</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>taotao-sso-service</artifactId><packaging>war</packaging><dependencies><dependency><groupId>com.taotao</groupId><artifactId>taotao-manager-dao</artifactId><version>0.0.1-SNAPSHOT</version></dependency><dependency><groupId>com.taotao</groupId><artifactId>taotao-sso-interface</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!-- Spring --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jms</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId></dependency><!-- dubbo相关的jar包 --><dependency><groupId>com.alibaba</groupId><artifactId>dubbo</artifactId><exclusions><exclusion><artifactId>spring</artifactId><groupId>org.springframework</groupId></exclusion><exclusion><artifactId>netty</artifactId><groupId>org.jboss.netty</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.zookeeper</groupId><artifactId>zookeeper</artifactId></dependency><dependency><groupId>com.github.sgroschupf</groupId><artifactId>zkclient</artifactId></dependency><!-- Redis客户端 --><dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId></dependency></dependencies>
</project>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID" version="2.5"><display-name>taotao-sso</display-name><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list><!-- 初始化spring容器 --><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring/applicationContext-*.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener></web-app>

applicationContext-trans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd"><!-- 事务管理器 --><bean id="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><!-- 数据源 --><property name="dataSource" ref="dataSource" /></bean><!-- 通知 --><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><!-- 传播行为 --><tx:method name="save*" propagation="REQUIRED" /><tx:method name="insert*" propagation="REQUIRED" /><tx:method name="add*" propagation="REQUIRED" /><tx:method name="create*" propagation="REQUIRED" /><tx:method name="delete*" propagation="REQUIRED" /><tx:method name="update*" propagation="REQUIRED" /><tx:method name="find*" propagation="SUPPORTS" read-only="true" /><tx:method name="select*" propagation="SUPPORTS" read-only="true" /><tx:method name="get*" propagation="SUPPORTS" read-only="true" /></tx:attributes></tx:advice><!-- 切面 --><aop:config><aop:advisor advice-ref="txAdvice"pointcut="execution(* com.taotao.sso.service.*.*(..))" /></aop:config></beans>

applicationContext-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsdhttp://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd"><!-- 配置包扫描器,扫描所有带@Service注解的类 --><context:component-scan base-package="com.taotao.sso.service"/><!-- 发布dubbo服务 --><!-- 提供方应用信息,用于计算依赖关系 --><dubbo:application name="taotao-sso" /><!-- 注册中心的地址 --><dubbo:registry protocol="zookeeper" address="192.168.25.167:2181" /><!-- 用dubbo协议在20880端口暴露服务 --><dubbo:protocol name="dubbo" port="20883" /><!-- 声明需要暴露的服务接口 --><dubbo:service interface="com.taotao.sso.service.UserService" ref="userServiceImpl" timeout="300000"/>
</beans>

applicationContext-redis.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd"><context:annotation-config/><!-- redis单机版 --><bean id="jedisPool" class="redis.clients.jedis.JedisPool"><constructor-arg name="host" value="192.168.25.153"/>  <constructor-arg name="port" value="6379"/> </bean><bean id="jedisClientPool" class="com.taotao.jedis.JedisClientPool"/><!-- redis集群 --><!-- <bean id="jedisCluster" class="redis.clients.jedis.JedisCluster"><constructor-arg><set><bean class="redis.clients.jedis.HostAndPort"><constructor-arg name="host" value="192.168.25.153"/><constructor-arg name="port" value="7001"/></bean><bean class="redis.clients.jedis.HostAndPort"><constructor-arg name="host" value="192.168.25.153"/><constructor-arg name="port" value="7002"/></bean><bean class="redis.clients.jedis.HostAndPort"><constructor-arg name="host" value="192.168.25.153"/><constructor-arg name="port" value="7003"/></bean><bean class="redis.clients.jedis.HostAndPort"><constructor-arg name="host" value="192.168.25.153"/><constructor-arg name="port" value="7004"/></bean><bean class="redis.clients.jedis.HostAndPort"><constructor-arg name="host" value="192.168.25.153"/><constructor-arg name="port" value="7005"/></bean><bean class="redis.clients.jedis.HostAndPort"><constructor-arg name="host" value="192.168.25.153"/><constructor-arg name="port" value="7006"/></bean></set></constructor-arg></bean><bean id="jedisClientCluster" class="com.taotao.jedis.JedisClientCluster"/> -->
</beans>

applicationContext-dao.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd"><!-- 配置数据库连接池 --><!-- 加载配置文件 --><context:property-placeholder location="classpath:properties/*.properties" /><!-- 数据库连接池 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"destroy-method="close"><property name="url" value="${jdbc.url}" /><property name="username" value="${jdbc.username}" /><property name="password" value="${jdbc.password}" /><property name="driverClassName" value="${jdbc.driver}" /><property name="maxActive" value="10" /><property name="minIdle" value="5" /></bean><!-- SqlSessionFactory --><!-- 让spring管理sqlsessionfactory 使用mybatis和spring整合包中的 --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 数据库连接池 --><property name="dataSource" ref="dataSource" /><!-- 加载mybatis的全局配置文件 --><property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" /></bean><!-- Mapper映射文件的包扫描器 --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.taotao.mapper" /></bean></beans>

resource.properties

#redis\u4e2d\u7528\u6237Session\u7684\u524d\u7f00
USER_SESSION=USER_SESSION
#session\u7684\u8fc7\u671f\u65f6\u95f4
SESSION_EXPIRE=1800

db.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/taotao?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root

SqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configurationPUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><!-- 配置分页插件 --><plugins><plugin interceptor="com.github.pagehelper.PageHelper"><!-- 配置数据库的方言 --><!-- 设置数据库类型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库-->        <property name="dialect" value="mysql"/></plugin></plugins>
</configuration>
package com.taotao.sso.service.impl;import java.util.Date;
import java.util.List;
import java.util.UUID;import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;import com.taotao.common.pojo.TaotaoResult;
import com.taotao.common.utils.JsonUtils;
import com.taotao.jedis.JedisClient;
import com.taotao.mapper.TbUserMapper;
import com.taotao.pojo.TbUser;
import com.taotao.pojo.TbUserExample;
import com.taotao.pojo.TbUserExample.Criteria;
import com.taotao.sso.service.UserService;/*** 用户处理Service* <p>Title: UserServiceImpl</p>* <p>Description: </p>* <p>Company: www.itcast.cn</p> * @version 1.0*/
@Service
public class UserServiceImpl implements UserService {@Autowiredprivate TbUserMapper userMapper;@Autowiredprivate JedisClient jedisClient;@Value("${USER_SESSION}")private String USER_SESSION;@Value("${SESSION_EXPIRE}")private Integer SESSION_EXPIRE;@Overridepublic TaotaoResult checkData(String data, int type) {TbUserExample example = new TbUserExample();Criteria criteria = example.createCriteria();//设置查询条件//1.判断用户名是否可用if (type == 1) {criteria.andUsernameEqualTo(data);//2判断手机号是否可以使用} else if (type == 2) {criteria.andPhoneEqualTo(data);//3判断邮箱是否可以使用} else if (type == 3) {criteria.andEmailEqualTo(data);} else {return TaotaoResult.build(400, "参数中包含非法数据");}//执行查询List<TbUser> list = userMapper.selectByExample(example);if (list !=null && list.size() > 0) {//查询到数据,返回falsereturn TaotaoResult.ok(false);}//数据可以使用return TaotaoResult.ok(true);}@Overridepublic TaotaoResult register(TbUser user) {//检查数据的有效性if (StringUtils.isBlank(user.getUsername())) {return TaotaoResult.build(400, "用户名不能为空");}//判断用户名是否重复TaotaoResult taotaoResult = checkData(user.getUsername(), 1);if (!(boolean) taotaoResult.getData()) {return TaotaoResult.build(400, "用户名重复");}//判断密码是否为空if (StringUtils.isBlank(user.getPassword())) {return TaotaoResult.build(400, "密码不能为空");}if (StringUtils.isNotBlank(user.getPhone())) {//是否重复校验taotaoResult = checkData(user.getPhone(), 2);if (!(boolean) taotaoResult.getData()) {return TaotaoResult.build(400, "电话号码重复");}}//如果email不为空的话进行是否重复校验if (StringUtils.isNotBlank(user.getEmail())) {//是否重复校验taotaoResult = checkData(user.getEmail(), 3);if (!(boolean) taotaoResult.getData()) {return TaotaoResult.build(400, "email重复");}}//补全pojo的属性user.setCreated(new Date());user.setUpdated(new Date());//密码要进行md5加密String md5Pass = DigestUtils.md5DigestAsHex(user.getPassword().getBytes());user.setPassword(md5Pass);//插入数据userMapper.insert(user);//返回注册成功return TaotaoResult.ok();}@Overridepublic TaotaoResult login(String username, String password) {//判断用户名和密码是否正确TbUserExample example = new TbUserExample();Criteria criteria = example.createCriteria();criteria.andUsernameEqualTo(username);List<TbUser> list = userMapper.selectByExample(example);if (list == null || list.size() == 0) {//返回登录失败return TaotaoResult.build(400, "用户名或密码不正确");}TbUser user = list.get(0);//密码要进行md5加密然后再校验if (!DigestUtils.md5DigestAsHex(password.getBytes()).equals(user.getPassword())) {//返回登录失败return TaotaoResult.build(400, "用户名或密码不正确");}//生成token,使用uuidString token = UUID.randomUUID().toString();//清空密码user.setPassword(null);//把用户信息保存到redis,key就是token,value就是用户信息jedisClient.set(USER_SESSION + ":" + token, JsonUtils.objectToJson(user));//设置key的过期时间jedisClient.expire(USER_SESSION + ":" + token, SESSION_EXPIRE);//返回登录成功,其中要把token返回。return TaotaoResult.ok(token);}@Overridepublic TaotaoResult getUserByToken(String token) {String json = jedisClient.get(USER_SESSION + ":" + token);if (StringUtils.isBlank(json)) {return TaotaoResult.build(400, "用户登录已经过期");}//重置Session的过期时间jedisClient.expire(USER_SESSION + ":" + token, SESSION_EXPIRE);//把json转换成User对象TbUser user = JsonUtils.jsonToPojo(json, TbUser.class);return TaotaoResult.ok(user);//return TaotaoResult.ok(json);}}
package com.taotao.jedis;import org.springframework.beans.factory.annotation.Autowired;import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;public class JedisClientPool implements JedisClient {@Autowiredprivate JedisPool jedisPool;@Overridepublic String set(String key, String value) {Jedis jedis = jedisPool.getResource();String result = jedis.set(key, value);jedis.close();return result;}@Overridepublic String get(String key) {Jedis jedis = jedisPool.getResource();String result = jedis.get(key);jedis.close();return result;}@Overridepublic Boolean exists(String key) {Jedis jedis = jedisPool.getResource();Boolean result = jedis.exists(key);jedis.close();return result;}@Overridepublic Long expire(String key, int seconds) {Jedis jedis = jedisPool.getResource();Long result = jedis.expire(key, seconds);jedis.close();return result;}@Overridepublic Long ttl(String key) {Jedis jedis = jedisPool.getResource();Long result = jedis.ttl(key);jedis.close();return result;}@Overridepublic Long incr(String key) {Jedis jedis = jedisPool.getResource();Long result = jedis.incr(key);jedis.close();return result;}@Overridepublic Long hset(String key, String field, String value) {Jedis jedis = jedisPool.getResource();Long result = jedis.hset(key, field, value);jedis.close();return result;}@Overridepublic String hget(String key, String field) {Jedis jedis = jedisPool.getResource();String result = jedis.hget(key, field);jedis.close();return result;}@Overridepublic Long hdel(String key, String... field) {Jedis jedis = jedisPool.getResource();Long result = jedis.hdel(key, field);jedis.close();return result;}}
package com.taotao.jedis;import org.springframework.beans.factory.annotation.Autowired;import redis.clients.jedis.JedisCluster;public class JedisClientCluster implements JedisClient {@Autowiredprivate JedisCluster jedisCluster;@Overridepublic String set(String key, String value) {return jedisCluster.set(key, value);}@Overridepublic String get(String key) {return jedisCluster.get(key);}@Overridepublic Boolean exists(String key) {return jedisCluster.exists(key);}@Overridepublic Long expire(String key, int seconds) {return jedisCluster.expire(key, seconds);}@Overridepublic Long ttl(String key) {return jedisCluster.ttl(key);}@Overridepublic Long incr(String key) {return jedisCluster.incr(key);}@Overridepublic Long hset(String key, String field, String value) {return jedisCluster.hset(key, field, value);}@Overridepublic String hget(String key, String field) {return jedisCluster.hget(key, field);}@Overridepublic Long hdel(String key, String... field) {return jedisCluster.hdel(key, field);}}
package com.taotao.jedis;public interface JedisClient {String set(String key, String value);String get(String key);Boolean exists(String key);Long expire(String key, int seconds);Long ttl(String key);Long incr(String key);Long hset(String key, String field, String value);String hget(String key, String field);Long hdel(String key, String... field);
}

taotao-sso-interface

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.taotao</groupId><artifactId>taotao-sso</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>taotao-sso-interface</artifactId><dependencies><dependency><groupId>com.taotao</groupId><artifactId>taotao-manager-pojo</artifactId><version>0.0.1-SNAPSHOT</version></dependency></dependencies>
</project>
package com.taotao.sso.service;import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbUser;public interface UserService {TaotaoResult checkData(String data, int type);TaotaoResult register(TbUser user);TaotaoResult login(String username, String password);TaotaoResult getUserByToken(String token);
}

taotao-search-web

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.taotao</groupId><artifactId>taotao-parent</artifactId><version>0.0.1-SNAPSHOT</version></parent><groupId>com.taotao</groupId><artifactId>taotao-search-web</artifactId><version>0.0.1-SNAPSHOT</version><packaging>war</packaging><dependencies><dependency><groupId>com.taotao</groupId><artifactId>taotao-common</artifactId><version>0.0.1-SNAPSHOT</version></dependency><dependency><groupId>com.taotao</groupId><artifactId>taotao-search-interface</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!-- Spring --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jms</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId></dependency><!-- JSP相关 --><dependency><groupId>jstl</groupId><artifactId>jstl</artifactId></dependency><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><scope>provided</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jsp-api</artifactId><scope>provided</scope></dependency><!-- dubbo相关的jar包 --><dependency><groupId>com.alibaba</groupId><artifactId>dubbo</artifactId><exclusions><exclusion><artifactId>spring</artifactId><groupId>org.springframework</groupId></exclusion><exclusion><artifactId>netty</artifactId><groupId>org.jboss.netty</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.zookeeper</groupId><artifactId>zookeeper</artifactId></dependency><dependency><groupId>com.github.sgroschupf</groupId><artifactId>zkclient</artifactId></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><configuration><path>/</path><port>8085</port></configuration></plugin></plugins></build>
</project>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID" version="2.5"><display-name>taotao-search-web</display-name><welcome-file-list><welcome-file>index.html</welcome-file></welcome-file-list><!-- post乱码过滤器 --><filter><filter-name>CharacterEncodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>utf-8</param-value></init-param></filter><filter-mapping><filter-name>CharacterEncodingFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><!-- 前端控制器 --><servlet><servlet-name>taotao-search-web</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><!-- contextConfigLocation不是必须的, 如果不配置contextConfigLocation, springmvc的配置文件默认在:WEB-INF/servlet的name+"-servlet.xml" --><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring/springmvc.xml</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>taotao-search-web</servlet-name><!-- 伪静态化 --><url-pattern>*.html</url-pattern></servlet-mapping></web-app>

search.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Cache-Control" content="max-age=300" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${query} - 商品搜索 - 淘淘</title>
<meta name="Keywords" content="java,淘淘java" />
<meta name="description" content="在淘淘中找到了29910件java的类似商品,其中包含了“图书”,“电子书”,“教育音像”,“骑行运动”等类型的java的商品。" />
<link rel="stylesheet" type="text/css" href="/css/base.css" media="all" />
<link rel="stylesheet" type="text/css" href="/css/psearch20131008.css" media="all" />
<link rel="stylesheet" type="text/css" href="/css/psearch.onebox.css" media="all" />
<link rel="stylesheet" type="text/css" href="/css/pop_compare.css" media="all" />
<script type="text/javascript" src="/js/jquery-1.6.4.js"></script>
</head>
<body>
<script type="text/javascript" src="/js/base-2011.js" charset="utf-8"></script>
<!-- header start -->
<jsp:include page="commons/header.jsp" />
<!-- header end -->
<div class="w main"><div class="crumb">全部结果&nbsp;&gt;&nbsp;<strong>"${query}"</strong></div>
<div class="clr"></div>
<div class="m clearfix" id="bottom_pager">
<div  id="pagin-btm" class="pagin fr" clstag="search|keycount|search|pre-page2"><span class="prev-disabled">上一页<b></b></span><a href="javascript:void(0)" class="current">1</a><a href="search?keyword=java&enc=utf-8&qr=&qrst=UNEXPAND&rt=1&page=2">2</a><a href="search?keyword=java&enc=utf-8&qr=&qrst=UNEXPAND&rt=1&page=3">3</a><a href="search?keyword=java&enc=utf-8&qr=&qrst=UNEXPAND&rt=1&page=4">4</a><a href="search?keyword=java&enc=utf-8&qr=&qrst=UNEXPAND&rt=1&page=5">5</a><a href="search?keyword=java&enc=utf-8&qr=&qrst=UNEXPAND&rt=1&page=6">6</a><span class="text">…</span><a href="search?keyword=java&enc=utf-8&qr=&qrst=UNEXPAND&rt=1&page=2" class="next">下一页<b></b></a><span class="page-skip"><em>&nbsp;&nbsp;共${totalPages}页&nbsp;&nbsp;&nbsp;&nbsp;到第</em></span>
</div>
</div>
<div class="m psearch " id="plist">
<ul class="list-h clearfix" tpl="2">
<c:forEach items="${itemList}" var="item">
<li class="item-book" bookid="11078102"><div class="p-img"><a target="_blank" href="http://localhost:8086/item/${item.id }.html"><img width="160" height="160" data-img="1" data-lazyload="${item.image}" /></a></div><div class="p-name"><a target="_blank" href="http://localhost:8086/item/${item.id }.html">${item.title}</a></div><div class="p-price"><i>淘淘价:</i><strong>¥<fmt:formatNumber groupingUsed="false" maxFractionDigits="2" minFractionDigits="2" value="${item.price / 100 }"/></strong></div><div class="service">由 淘淘 发货</div><div class="extra"><span class="star"><span class="star-white"><span class="star-yellow h5">&nbsp;</span></span></span></div>
</li>
</c:forEach>
</ul></div>
</div>
<!-- footer start -->
<jsp:include page="commons/footer.jsp" />
<!-- footer end -->
<script type="text/javascript" src="/js/jquery.hashchange.js"></script>
<script type="text/javascript" src="/js/search_main.js"></script>
<script type="text/javascript">
//${paginator.totalPages}
SEARCH.query = "${query}";
SEARCH.bottom_page_html(${page},${totalPages},'');
</script>
</body>
</html>

exception.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport"content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>出错了 -淘淘商城</title>
<!--结算页面样式-->
<link rel="stylesheet" type="text/css" href="/css/base.css" media="all" />
<link type="text/css" rel="stylesheet" href="/css/order-commons.css"source="widget" />
<script type="text/javascript" src="/js/jquery-1.6.4.js"></script>
<script type="text/javascript" src="/js/base.js"></script>
<script type="text/javascript" src="/js/order.common.js"></script>
<script type="text/javascript" src="/js/jquery.checkout.js"></script>
</head>
<body id="mainframe"><div class="w w1 header clearfix"><div id="logo"><a href="/"><img src="/images/taotao-logo.gif" alt="淘淘商城"></a></div></div><div class="w"><div id="refresh"><style type="text/css">
#refresh {text-align: left;margin: 30px auto;width: 750px;height: 220px;background:url(/images/errordog.jpg)0 0;position: relative
}#refresh .txt {position: absolute;left: 236px;top: 16px;color: #fff;font-size: 14px;font-family: "microsoft yahei"
}#refresh .m {position: absolute;left: 336px;top: 80px;line-height: 18px;font-size: 14px
}#refresh .m li {padding-bottom: 8px
}#refresh .m a {color: #005eab
}#refresh .m .fore1, #refresh .m .fore2 {font-family: "microsoft yahei"
}#refresh .m .fore1 a {color: #e4393c
}#refresh .m .fore2 a {color: #e4393c;font-weight: bold;font-size: 18px;padding: 0 3px
}#refresh .m .fore3 {font-weight: bold;font-size: 12px
}#refresh .m .fore4 a {margin-right: 15px;font-size: 12px
}</style><span class="txt">糟了...系统出错了...</span><ul class="m"><li class="fore1">您可以:稍后再试或联系客服400-8888-9999。</li><li class="fore2">返回<a href="/" target="_blank">淘淘首页</a></li><li class="fore3">错误消息</li><li class="fore4">${message }</li></ul></div></div><!-- footer start --><jsp:include page="../commons/footer.jsp" /><!-- footer end -->
</body>
</html>

shortcut.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div id="shortcut-2013"><div class="w"><ul class="fl lh"><li class="fore1 ld" clstag="homepage|keycount|home2013|01a"><b></b><a href="javascript:addToFavorite()" rel="nofollow">收藏淘淘</a></li></ul><ul class="fr lh"><li class="fore1" id="loginbar" clstag="homepage|keycount|home2013|01b">您好!欢迎来到淘淘!<a href="javascript:login()">[登录]</a>&nbsp;<a href="javascript:regist()">[免费注册]</a></li><li class="fore2 ld" clstag="homepage|keycount|home2013|01c"><s></s><a href="http://jd2008.jd.com/JdHome/OrderList.aspx" rel="nofollow">我的订单</a></li><li class="fore2-1 ld" id="jd-vip"><s></s><a target="_blank" rel="nofollow" href="http://vip.jd.com">会员俱乐部</a></li><li class="fore3 ld menu" id="app-jd" data-widget="dropdown" clstag="homepage|keycount|home2013|01d"><s></s><i></i><span class="outline"></span><span class="blank"></span><a href="http://app.jd.com/" target="_blank">手机淘淘</a><b></b></li><li class="fore4 ld menu" id="biz-service" data-widget="dropdown" clstag="homepage|keycount|home2013|01e"><s></s><span class="outline"></span><span class="blank"></span>客户服务<b></b><div class="dd"><div><a href="http://help.jd.com/index.html" target="_blank">帮助中心</a></div><div><a href="http://myjd.jd.com/repair/orderlist.action" target="_blank" rel="nofollow">售后服务</a></div><div><a href="http://chat.jd.com/jdchat/custom.action" target="_blank" rel="nofollow">在线客服</a></div><div><a href="http://myjd.jd.com/opinion/list.action" target="_blank" rel="nofollow">投诉中心</a></div><div><a href="http://www.jd.com/contact/service.html" target="_blank">客服邮箱</a></div></div></li><li class="fore5 ld menu" id="site-nav" data-widget="dropdown" clstag="homepage|keycount|home2013|01f"><s></s><span class="outline"></span><span class="blank"></span>网站导航<b></b><div class="dd lh"><dl class="item fore1"><dt>特色栏目</dt><dd><div><a target="_blank" href="http://mobile.jd.com/index.do">淘淘通信</a></div><div><a target="_blank" href="http://jdstar.jd.com/">校园之星</a></div><div><a target="_blank" href="http://my.jd.com/personal/guess.html">为我推荐</a></div><div><a target="_blank" href="http://shipingou.jd.com/">视频购物</a></div><div><a target="_blank" href="http://club.jd.com/">淘淘社区</a></div><div><a target="_blank" href="http://read.jd.com/">在线读书</a></div><div><a target="_blank" href="http://diy.jd.com/">装机大师</a></div><div><a target="_blank" href="http://giftcard.jd.com/market/index.action">淘淘E卡</a></div><div><a target="_blank" href="http://channel.jd.com/jiazhuang.html">家装城</a></div><div><a target="_blank" href="http://dapeigou.jd.com/">搭配购</a></div><div><a target="_blank" href="http://xihuan.jd.com/">我喜欢</a></div></dd></dl><dl class="item fore2"><dt>企业服务</dt><dd><div><a target="_blank" href="http://giftcard.jd.com/company/index">企业客户</a></div><div><a target="_blank" href="http://sale.jd.com/p10997.html">办公直通车</a></div></dd></dl><dl class="item fore3"><dt>旗下网站</dt><dd><div><a target="_blank" href="http://en.jd.com/">English Site</a></div></dd></dl></div></li></ul><span class="clr"></span></div>
</div>

header.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<script type="text/javascript" src="/js/base-v1.js" charset="utf-8"></script>
<!--shortcut start-->
<jsp:include page="shortcut.jsp" />
<!--shortcut end-->
<div id="o-header-2013"><div class="w" id="header-2013"><div id="logo-2013" class="ld"><a href="/" hidefocus="true" clstag="homepage|keycount|home2013|02a"><b></b><img src="/images/taotao-logo.gif" width="270" height="60" alt="淘淘"></a></div><!--logo end--><div id="search-2013"><div class="i-search ld"><ul id="shelper" class="hide"></ul><div class="form"><input type="text" class="text" accesskey="s" id="key" autocomplete="off" onkeydown="javascript:if(event.keyCode==13) search('key');"><input type="button" value="搜索" class="button" onclick="search('key');return false;" clstag="homepage|keycount|home2013|03a"></div></div><div id="hotwords" clstag="homepage|keycount|home2013|03b"></div></div><!--search end--><div id="my360buy-2013"><dl><dt class="ld"><s></s><a href="http://localhost:8084/user/showLogin" clstag="homepage|keycount|home2012|04a">我的淘淘</a><b></b></dt><dd><div class="loading-style1"><b></b>加载中,请稍候...</div></dd></dl></div><!--my360buy end--><div id="settleup-2013" clstag="homepage|keycount|home2013|05a"><dl><dt class="ld"><s></s><span class="shopping"><span id="shopping-amount"></span></span><a href="/cart/cart.html" id="settleup-url">去购物车结算</a> <b></b> </dt>
<!--                 <dd><div class="prompt"><div class="loading-style1"><b></b>加载中,请稍候...</div></div></dd>-->           </dl></div><!--settleup end--></div><!--header end--><div class="w"><div id="nav-2013"><div id="categorys-2013" class="categorys-2014"><div class="mt ld"><h2><a href="http://www.jd.com/allSort.aspx" clstag="homepage|keycount|home2013|06a">全部商品分类<b></b></a></h2></div><div id="_JD_ALLSORT" class="mc"><div class="item fore1"><span data-split="1"><h3><a href="/products/1.html">图书、音像、电子书刊</a></h3><s></s></span></div><div class="item fore2"><span data-split="1"><h3><a href="/products/74.html">家用电器</a></h3><s></s></span></div><div class="item fore3"><span data-split="1"><h3><a href="/products/161.html">电脑、办公</a></h3><s></s></span></div><div class="item fore4"><span data-split="1"><h3><a href="/products/249.html">个护化妆</a></h3><s></s></span></div><div class="item fore5"><span data-split="1"><h3><a href="/products/290.html">钟表</a></h3><s></s></span></div><div class="item fore6"><span data-split="1"><h3><a href="/products/296.html">母婴</a></h3><s></s></span></div><div class="item fore7"><span data-split="1"><h3><a href="/products/378.html">食品饮料、保健食品</a></h3><s></s></span></div><div class="item fore8"><span data-split="1"><h3><a href="/products/438.html">汽车用品</a></h3><s></s></span></div><div class="item fore9"><span data-split="1"><h3><a href="/products/495.html">玩具乐器</a></h3><s></s></span></div><div class="item fore10"><span data-split="1"><h3><a href="/products/558.html">手机</a></h3><s></s></span></div><div class="item fore11"><span data-split="1"><h3><a href="/products/580.html">数码</a></h3><s></s></span></div><div class="item fore12"><span data-split="1"><h3><a href="/products/633.html">家居家装</a></h3><s></s></span></div><div class="item fore13"><span data-split="1"><h3><a href="/products/699.html">厨具</a></h3><s></s></span></div><div class="item fore14"><span data-split="1"><h3><a href="/products/749.html">服饰内衣</a></h3><s></s></span></div><div class="extra"><a {if="" pageconfig.ishome}clstag="homepage|keycount|home2013|0614a"{="" if}="" href="http://www.jd.com/allSort.aspx">全部商品分类</a></div></div></div><div id="treasure" clstag="homepage|keycount|home2013|08a"></div><ul id="navitems-2013"><li class="fore1" id="nav-home" clstag="homepage|keycount|home2013|07a"><a href="/">首页</a></li><li class="fore2" id="nav-fashion" clstag="homepage|keycount|home2013|07b"><a href="http://fashion.jd.com/">服装城</a></li><li class="fore3" id="nav-chaoshi" clstag="homepage|keycount|home2013|07c"><a href="http://channel.jd.com/chaoshi.html">食品</a></li><li class="fore4" id="nav-tuan" clstag="homepage|keycount|home2013|07d"><a href="http://tuan.jd.com/" target="_blank">团购</a></li><li class="fore5" id="nav-auction" clstag="homepage|keycount|home2013|07e"><a href="http://auction.jd.com/">夺宝岛</a></li><li class="fore6" id="nav-shan" clstag="homepage|keycount|home2013|07f"><a href="http://red.jd.com/" target="_blank">闪购</a></li><li class="fore7" id="nav-jinrong" clstag="homepage|keycount|home2013|07g1"><a href="http://jr.jd.com/" target="_blank">金融</a></li></ul></div></div>
</div>
<script type="text/javascript">
(function(){if(pageConfig.navId){var object=document.getElementById("nav-"+pageConfig.navId);if(object)object.className+=" curr";}})();
</script>

footer-links.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<div id="footer-2013"><div class="links"><a href="http://www.jd.com/intro/about.aspx" target="_blank" rel="nofollow">关于我们</a>|<a href="http://www.jd.com/contact/" target="_blank" rel="nofollow">联系我们</a>|<a href="http://zhaopin.jd.com/" target="_blank" rel="nofollow">人才招聘</a>|<a href="http://www.jd.com/contact/joinin.aspx" target="_blank" rel="nofollow">商家入驻</a>|<a href="http://jzt.jd.com" target="_blank" rel="nofollow">营销中心</a>|<a href="http://app.jd.com/" target="_blank" rel="nofollow">手机淘淘</a>|<a href="http://club.jd.com/links.aspx" target="_blank">友情链接</a>|<a href="http://media.jd.com/" target="_blank">销售联盟</a>|<a target="_blank" href="http://club.jd.com/">淘淘社区</a>|<a target="_blank" href="http://gongyi.jd.com">淘淘公益</a>|<a target="_blank" href="http://en.jd.com/">English Site</a></div>
</div>

footer.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<div class="w" clstag="homepage|keycount|home2013|37a"><div id="service-2013"><dl class="fore1"><dt><b></b><strong>购物指南</strong></dt><dd><div><a href="http://help.jd.com/help/question-56.html" target="_blank" rel="nofollow">购物流程</a></div><div><a href="http://help.jd.com/help/question-57.html" target="_blank" rel="nofollow">会员介绍</a></div><div><a href="http://help.jd.com/help/question-181.html" target="_blank" rel="nofollow">团购/机票</a></div><div><a href="http://help.jd.com/help/question-61.html" target="_blank" rel="nofollow">常见问题</a></div><div><a href="http://help.jd.com/help/question-63.html" target="_blank" rel="nofollow">大家电</a></div><div><a href="http://help.jd.com/index.html" target="_blank" rel="nofollow">联系客服</a></div></dd></dl><dl class="fore2">        <dt><b></b><strong>配送方式</strong></dt><dd><div><a href="http://help.jd.com/help/question-64.html" target="_blank" rel="nofollow">上门自提</a></div><div><a href="http://help.jd.com/help/question-360.html" target="_blank" rel="nofollow">211限时达</a></div><div><a href="http://help.jd.com/help/distribution-768.html" target="_blank" rel="nofollow">配送服务查询</a></div><div><a href="http://help.jd.com/help/question-892.html#help2215" target="_blank" rel="nofollow">配送费收取标准</a></div><div><a href="http://market.jd.com/giftcard/index.html#one5" target="_blank" rel="nofollow">如何送礼</a></div><div><a href="http://en.jd.com/chinese.html" target="_blank">海外配送</a></div></dd></dl><dl class="fore3"><dt><b></b><strong>支付方式</strong></dt><dd><div><a href="http://help.jd.com/help/question-67.html" target="_blank" rel="nofollow">货到付款</a></div><div><a href="http://help.jd.com/help/question-68.html" target="_blank" rel="nofollow">在线支付</a></div><div><a href="http://help.jd.com/help/question-71.html" target="_blank" rel="nofollow">分期付款</a></div><div><a href="http://help.jd.com/help/question-69.html" target="_blank" rel="nofollow">邮局汇款</a></div><div><a href="http://help.jd.com/help/question-70.html" target="_blank" rel="nofollow">公司转账</a></div></dd></dl><dl class="fore4">       <dt><b></b><strong>售后服务</strong></dt><dd><div><a href="http://myjd.jd.com/afs/help/afshelp.action" target="_blank" rel="nofollow">售后政策</a></div><div><a href="http://help.jd.com/help/question-99.html" target="_blank" rel="nofollow">价格保护</a></div><div><a href="http://help.jd.com/help/question-100.html" target="_blank" rel="nofollow">退款说明</a></div><div><a href="http://myjd.jd.com/repair/repairs.action" target="_blank" rel="nofollow">返修/退换货</a></div><div><a href="http://help.jd.com/help/question-881.html" target="_blank" rel="nofollow">取消订单</a></div></dd></dl><dl class="fore5"><dt><b></b><strong>特色服务</strong></dt><dd>     <div><a href="http://help.jd.com/help/question-79.html" target="_blank">夺宝岛</a></div><div><a href="http://help.jd.com/help/question-86.html" target="_blank">DIY装机</a></div><div><a href="http://fuwu.jd.com/" target="_blank" rel="nofollow">延保服务</a></div><div><a href="http://giftcard.jd.com/market/index.action" target="_blank" rel="nofollow">淘淘E卡</a></div><div><a href="http://help.jd.com/help/question-91.html" target="_blank" rel="nofollow">节能补贴</a></div><div><a href="http://mobile.jd.com/" target="_blank" rel="nofollow">淘淘通信</a></div></dd></dl><div class="fr"><div class="sm" id="branch-office"><div class="smt"><h3>淘淘自营覆盖区县</h3></div><div class="smc"><p>淘淘已向全国1859个区县提供自营配送服务,支持货到付款、POS机刷卡和售后上门服务。</p><p class="ar"><a href="http://help.jd.com/help/distribution-768.html" target="_blank">查看详情&nbsp;></a></p></div></div></div><span class="clr"></span></div>
</div>
<div class="w" clstag="homepage|keycount|home2013|38a"><jsp:include page="footer-links.jsp"></jsp:include>
</div>
<script type="text/javascript" src="/js/jquery-1.6.4.js"></script>
<script type="text/javascript" src="/js/jquery-extend.js"></script>
<script type="text/javascript" src="/js/lib-v1.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/taotao.js" charset="utf-8"></script>
<script type="text/javascript"> (function(){
var A="<strong>热门搜索:</strong><a href='http://sale.jd.com/act/OfHQzJ2GLoYlmTIu.html' target='_blank' style='color:#ff0000' clstag='homepage|keycount|home2013|03b1'>校园之星</a><a href='http://sale.jd.com/act/aEBHqLFMfVzDZUvu.html' target='_blank'>办公打印</a><a href='http://www.jd.com/pinpai/878-12516.html' target='_blank'>美菱冰箱</a><a href='http://sale.jd.com/act/nuzKb6ZiYL.html' target='_blank'>无肉不欢</a><a href='http://sale.jd.com/act/ESvhtcAJNbaj.html' target='_blank'>万件好货</a><a href='http://sale.jd.com/act/nAqiWgU34frQolt.html' target='_blank'>iPhone6</a><a href='http://sale.jd.com/act/p0CmUlEFPHLX.html' target='_blank'>哈利波特</a><a href='http://sale.jd.com/act/FstSdb2vCOLa8BRi.html' target='_blank'>美模接驾</a>";
var B=["java","apple","LG G3","天梭","保温杯","三个爸爸"];
B=pageConfig.FN_GetRandomData(B);
$("#hotwords").html(A);
var _searchValue = "${query}";
if(_searchValue.length == 0){_searchValue = B;
}
$("#key").val(_searchValue).bind("focus",function(){if (this.value==B){this.value="";this.style.color="#333"}}).bind("blur",function(){if (!this.value){this.value=B;this.style.color="#999"}});
})();
</script>

log4j.properties

log4j.rootLogger=INFO,A3,STDOUTlog4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=[%p] [%l] %10.10c - %m%nlog4j.appender.A3=org.apache.log4j.RollingFileAppender
log4j.appender.A3.file=logs/server.log
log4j.appender.A3.MaxFileSize=1024KB
log4j.appender.A3.MaxBackupIndex=10
log4j.appender.A3.layout=org.apache.log4j.PatternLayout
log4j.appender.A3.layout.ConversionPattern=\n\n[%-5p] %d{yyyy-MM-dd HH\:mm\:ss,SSS} method\:%l%n%m%n

springmvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsdhttp://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"><!-- 加载属性文件 --><context:property-placeholder location="classpath:resource/resource.properties"/><!-- 配置注解驱动 --><mvc:annotation-driven /><!-- 视图解析器 --><beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/jsp/" /><property name="suffix" value=".jsp" /></bean><!-- 配置全局异常处理器 --><bean class="com.taotao.search.exception.GlobalExceptionResolver"></bean><!-- 配置包扫描器,扫描@Controller注解的类 --><context:component-scan base-package="com.taotao.search.controller"/><!-- 引用dubbo服务 --><dubbo:application name="taotao-search-web"/><dubbo:registry protocol="zookeeper" address="192.168.25.167:2181"/> <dubbo:reference interface="com.taotao.search.service.SearchService" id="searchService" />
</beans>      

resource.properties

#\u641c\u7d22\u7ed3\u679c\u6bcf\u9875\u663e\u793a\u7684\u8bb0\u5f55\u6570
SEARCH_RESULT_ROWS=60
package com.taotao.search.exception;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;/*** 全局异常处理器* <p>Title: GlobalExceptionResolver</p>* <p>Description: </p>* <p>Company: www.itcast.cn</p> * @version 1.0*/
public class GlobalExceptionResolver implements HandlerExceptionResolver {private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionResolver.class);@Overridepublic ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception e) {logger.info("进入全局异常处理器。。。。。");logger.debug("测试handler的类型:" + handler.getClass());//控制台打印异常e.printStackTrace();//向日志文件中写入异常logger.error("系统发生异常", e);//发邮件//jmail//发短信//展示错误页面ModelAndView modelAndView = new ModelAndView();modelAndView.addObject("message", "您的电脑有问题,请稍后重试。");modelAndView.setViewName("error/exception");return modelAndView;}}
package com.taotao.search.controller;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;import com.taotao.common.pojo.SearchResult;
import com.taotao.search.service.SearchService;import javassist.compiler.ast.Pair;/*** 搜索服务Controller* <p>Title: SearchController</p>* <p>Description: </p>* <p>Company: www.itcast.cn</p> * @version 1.0*/
@Controller
public class SearchController {@Autowiredprivate SearchService searchService;@Value("${SEARCH_RESULT_ROWS}")private Integer SEARCH_RESULT_ROWS;@RequestMapping("/search")public String search(@RequestParam("q")String queryString, @RequestParam(defaultValue="1")Integer page, Model model) throws Exception {//int a = 1/0;//调用服务执行查询//把查询条件进行转码,解决get乱码问题queryString = new String(queryString.getBytes("iso8859-1"), "utf-8");SearchResult searchResult = searchService.search(queryString, page, SEARCH_RESULT_ROWS);//把结果传递给页面model.addAttribute("query", queryString);model.addAttribute("totalPages", searchResult.getTotalPages());model.addAttribute("itemList", searchResult.getItemList());model.addAttribute("page", page);//返回逻辑视图return "search";}
}

Taotao-search

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.taotao</groupId><artifactId>taotao-parent</artifactId><version>0.0.1-SNAPSHOT</version></parent><groupId>com.taotao</groupId><artifactId>taotao-search</artifactId><version>0.0.1-SNAPSHOT</version><packaging>pom</packaging><modules><module>taotao-search-interface</module><module>taotao-search-service</module></modules><dependencies><dependency><groupId>com.taotao</groupId><artifactId>taotao-common</artifactId><version>0.0.1-SNAPSHOT</version></dependency></dependencies><build><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><configuration><path>/</path><port>8084</port></configuration></plugin></plugins></build>
</project>

taotao-search-service

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.taotao</groupId><artifactId>taotao-search</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>taotao-search-service</artifactId><packaging>war</packaging><dependencies><dependency><groupId>com.taotao</groupId><artifactId>taotao-manager-dao</artifactId><version>0.0.1-SNAPSHOT</version></dependency><dependency><groupId>com.taotao</groupId><artifactId>taotao-search-interface</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!-- Spring --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jms</artifactId></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId></dependency><!-- dubbo相关的jar包 --><dependency><groupId>com.alibaba</groupId><artifactId>dubbo</artifactId><exclusions><exclusion><artifactId>spring</artifactId><groupId>org.springframework</groupId></exclusion><exclusion><artifactId>netty</artifactId><groupId>org.jboss.netty</groupId></exclusion></exclusions></dependency><dependency><groupId>org.apache.zookeeper</groupId><artifactId>zookeeper</artifactId></dependency><dependency><groupId>com.github.sgroschupf</groupId><artifactId>zkclient</artifactId></dependency><!-- 添加solrJ的依赖 --><dependency><groupId>org.apache.solr</groupId><artifactId>solr-solrj</artifactId></dependency><!-- activemq的jar包 --><dependency><groupId>org.apache.activemq</groupId><artifactId>activemq-all</artifactId></dependency></dependencies><build><resources><resource><directory>src/main/java</directory><includes><include>**/*.xml</include></includes></resource><resource><directory>src/main/resources</directory><includes><include>**/*.xml</include><include>**/*.properties</include></includes></resource></resources></build>
</project>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID" version="2.5"><display-name>taotao-search</display-name><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list><!-- 初始化spring容器 --><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring/applicationContext-*.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener></web-app>

applicationContext-solr.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd"><!-- 单机版solr的连接 --><bean id="httpSolrServer" class="org.apache.solr.client.solrj.impl.HttpSolrServer"><constructor-arg name="baseURL" value="http://192.168.25.154:8080/solr/collection1"/></bean><!-- 集群版solr连接 --><!-- <bean id="cloudSolrServer" class="org.apache.solr.client.solrj.impl.CloudSolrServer"><constructor-arg name="zkHost" value="192.168.25.154:2181,192.168.25.154:2182,192.168.25.154:2183"></constructor-arg><property name="defaultCollection" value="collection2"/></bean> --></beans>

applicationContext-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsdhttp://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd"><!-- 配置包扫描器,扫描所有带@Service注解的类 --><context:component-scan base-package="com.taotao.search"/><!-- 发布dubbo服务 --><!-- 提供方应用信息,用于计算依赖关系 --><dubbo:application name="taotao-search" /><!-- 注册中心的地址 --><dubbo:registry protocol="zookeeper" address="192.168.25.167:2181" /><!-- 用dubbo协议在20880端口暴露服务 --><dubbo:protocol name="dubbo" port="20882" /><!-- 声明需要暴露的服务接口 --><dubbo:service interface="com.taotao.search.service.SearchItemService" ref="searchItemServiceImpl" timeout="300000"/><dubbo:service interface="com.taotao.search.service.SearchService" ref="searchServiceImpl" timeout="300000"/>
</beans>

applicationContext-dao.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd"><!-- 配置数据库连接池 --><!-- 加载配置文件 --><context:property-placeholder location="classpath:properties/*.properties" /><!-- 数据库连接池 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"destroy-method="close"><property name="url" value="${jdbc.url}" /><property name="username" value="${jdbc.username}" /><property name="password" value="${jdbc.password}" /><property name="driverClassName" value="${jdbc.driver}" /><property name="maxActive" value="10" /><property name="minIdle" value="5" /></bean><!-- SqlSessionFactory --><!-- 让spring管理sqlsessionfactory 使用mybatis和spring整合包中的 --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 数据库连接池 --><property name="dataSource" ref="dataSource" /><!-- 加载mybatis的全局配置文件 --><property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" /></bean><!-- Mapper映射文件的包扫描器 --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.taotao.mapper,com.taotao.search.mapper" /></bean></beans>

applicationContext-activemq.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd"><!-- JMS服务厂商提供的ConnectionFactory --><bean id="targetConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"><constructor-arg name="brokerURL" value="tcp://192.168.25.168:61616"/></bean><!-- spring对象ConnectionFactory的封装 --><bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory"><property name="targetConnectionFactory" ref="targetConnectionFactory"></property></bean><!-- 配置消息的Destination对象 --><bean id="test-queue" class="org.apache.activemq.command.ActiveMQQueue"><constructor-arg name="name" value="test-queue"></constructor-arg></bean><bean id="itemAddTopic" class="org.apache.activemq.command.ActiveMQTopic"><constructor-arg name="name" value="item-add-topic"></constructor-arg></bean><!-- 配置消息的接收者 --><bean id="myMessageListener" class="com.taotao.search.listener.MyMessageListener"/><bean class="org.springframework.jms.listener.DefaultMessageListenerContainer"><property name="connectionFactory" ref="connectionFactory" /><property name="destination" ref="test-queue" /><property name="messageListener" ref="myMessageListener" /></bean><bean id="itemAddMessageListener" class="com.taotao.search.listener.ItemAddMessageListener"/><bean class="org.springframework.jms.listener.DefaultMessageListenerContainer"><property name="connectionFactory" ref="connectionFactory" /><property name="destination" ref="itemAddTopic" /><property name="messageListener" ref="itemAddMessageListener" /></bean>
</beans>

db.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/taotao?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root

SqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configurationPUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><!-- 配置分页插件 --><plugins><plugin interceptor="com.github.pagehelper.PageHelper"><!-- 配置数据库的方言 --><!-- 设置数据库类型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库-->        <property name="dialect" value="mysql"/></plugin></plugins>
</configuration>
package com.taotao.search.service.impl;import org.apache.solr.client.solrj.SolrQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import com.taotao.common.pojo.SearchResult;
import com.taotao.search.dao.SearchDao;
import com.taotao.search.service.SearchService;/*** 搜索服务功能实现* <p>Title: SearchServiceImpl</p>* <p>Description: </p>* <p>Company: www.itcast.cn</p> * @version 1.0*/
@Service
public class SearchServiceImpl implements SearchService {@Autowiredprivate SearchDao searchDao;@Overridepublic SearchResult search(String queryString, int page, int rows) throws Exception {//根据查询条件拼装查询对象//创建一个SolrQuery对象SolrQuery query = new SolrQuery();//设置查询条件query.setQuery(queryString);//设置分页条件if (page < 1) page =1;query.setStart((page - 1) * rows);if (rows < 1) rows = 10;query.setRows(rows);//设置默认搜索域query.set("df", "item_title");//设置高亮显示query.setHighlight(true);query.addHighlightField("item_title");query.setHighlightSimplePre("<font color='red'>");query.setHighlightSimplePost("</font>");//调用dao执行查询SearchResult searchResult = searchDao.search(query);//计算查询结果的总页数long recordCount = searchResult.getRecordCount();long pages =  recordCount / rows;if (recordCount % rows > 0) {pages++;}searchResult.setTotalPages(pages);//返回结果return searchResult;}}
package com.taotao.search.service.impl;import java.util.List;import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.common.SolrInputDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import com.taotao.common.pojo.SearchItem;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.search.mapper.SearchItemMapper;
import com.taotao.search.service.SearchItemService;/*** 商品数据导入索引库* <p>Title: SearchItemServiceImpl</p>* <p>Description: </p>* <p>Company: www.itcast.cn</p> * @version 1.0*/
@Service
public class SearchItemServiceImpl implements SearchItemService {@Autowiredprivate SearchItemMapper searchItemMapper;@Autowiredprivate SolrServer solrServer;@Overridepublic TaotaoResult importItemsToIndex() {try {//1、先查询所有商品数据List<SearchItem> itemList = searchItemMapper.getItemList();//2、遍历商品数据添加到索引库for (SearchItem searchItem : itemList) {//创建文档对象SolrInputDocument document = new SolrInputDocument();//向文档中添加域document.addField("id", searchItem.getId());document.addField("item_title", searchItem.getTitle());document.addField("item_sell_point", searchItem.getSell_point());document.addField("item_price", searchItem.getPrice());document.addField("item_image", searchItem.getImage());document.addField("item_category_name", searchItem.getCategory_name());document.addField("item_desc", searchItem.getItem_desc());//把文档写入索引库solrServer.add(document);}//3、提交solrServer.commit();} catch (Exception e) {e.printStackTrace();return TaotaoResult.build(500, "数据导入失败");}//4、返回添加成功return TaotaoResult.ok();}}

SearchItemMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.taotao.search.mapper.SearchItemMapper" ><select id="getItemList" resultType="com.taotao.common.pojo.SearchItem">SELECTa.id,a.title,a.sell_point,a.price,a.image,b. NAME category_name,c.item_descFROMtb_item aLEFT JOIN tb_item_cat b ON a.cid = b.idLEFT JOIN tb_item_desc c ON a.id = c.item_idWHEREa.`status` = 1</select><select id="getItemById" parameterType="long" resultType="com.taotao.common.pojo.SearchItem">SELECTa.id,a.title,a.sell_point,a.price,a.image,b. NAME category_name,c.item_descFROMtb_item aLEFT JOIN tb_item_cat b ON a.cid = b.idLEFT JOIN tb_item_desc c ON a.id = c.item_idWHEREa.`status` = 1ANDa.id=#{itemId}</select></mapper>
package com.taotao.search.mapper;import java.util.List;import com.taotao.common.pojo.SearchItem;public interface SearchItemMapper {List<SearchItem> getItemList();SearchItem getItemById(long itemId);
}
package com.taotao.search.listener;import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.xml.soap.Text;/*** 接收Activemq发送的消息* <p>Title: MyMessageListener</p>* <p>Description: </p>* <p>Company: www.itcast.cn</p> * @version 1.0*/
public class MyMessageListener implements MessageListener {@Overridepublic void onMessage(Message message) {try {//接收到消息TextMessage textMessage = (TextMessage) message;String text = textMessage.getText();System.out.println(text);} catch (Exception e) {e.printStackTrace();}}}
package com.taotao.search.listener;import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.common.SolrInputDocument;
import org.springframework.beans.factory.annotation.Autowired;import com.taotao.common.pojo.SearchItem;
import com.taotao.search.mapper.SearchItemMapper;/*** 监听商品添加事件,同步索引库* <p>Title: ItemAddMessageListener</p>* <p>Description: </p>* <p>Company: www.itcast.cn</p> * @version 1.0*/
public class ItemAddMessageListener implements MessageListener{@Autowiredprivate SearchItemMapper searchItemMapper;@Autowiredprivate SolrServer solrServer;@Overridepublic void onMessage(Message message) {try {//从消息中取商品idTextMessage textMessage = (TextMessage) message;String text = textMessage.getText();long itemId = Long.parseLong(text);//根据商品id查询数据,取商品信息//等待事务提交Thread.sleep(1000);SearchItem searchItem = searchItemMapper.getItemById(itemId);//创建文档对象SolrInputDocument document = new SolrInputDocument();//向文档对象中添加域document.addField("id", searchItem.getId());document.addField("item_title", searchItem.getTitle());document.addField("item_sell_point", searchItem.getSell_point());document.addField("item_price", searchItem.getPrice());document.addField("item_image", searchItem.getImage());document.addField("item_category_name", searchItem.getCategory_name());document.addField("item_desc", searchItem.getItem_desc());//把文档对象写入索引库solrServer.add(document);//提交solrServer.commit();} catch (Exception e) {e.printStackTrace();}}}
package com.taotao.search.dao;import java.util.ArrayList;
import java.util.List;
import java.util.Map;import org.apache.commons.lang3.StringUtils;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;import com.taotao.common.pojo.SearchItem;
import com.taotao.common.pojo.SearchResult;/*** 查询索引库商品dao* <p>Title: SearchDao</p>* <p>Description: </p>* <p>Company: www.itcast.cn</p> * @version 1.0*/
@Repository
public class SearchDao {@Autowiredprivate SolrServer solrServer;public SearchResult search(SolrQuery query) throws Exception{//根据query对象进行查询QueryResponse response = solrServer.query(query);//取查询结果SolrDocumentList solrDocumentList = response.getResults();//取查询结果总记录数long numFound = solrDocumentList.getNumFound();SearchResult result = new SearchResult();result.setRecordCount(numFound);List<SearchItem> itemList = new ArrayList<>();//把查询结果封装到SearchItem对象中for (SolrDocument solrDocument : solrDocumentList) {SearchItem item = new SearchItem();item.setCategory_name((String) solrDocument.get("item_category_name"));item.setId((String) solrDocument.get("id"));//取一张图片String image = (String) solrDocument.get("item_image");if (StringUtils.isNotBlank(image)) {image = image.split(",")[0];}item.setImage(image);item.setPrice((long) solrDocument.get("item_price"));item.setSell_point((String) solrDocument.get("item_sell_point"));//取高亮显示Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();List<String> list = highlighting.get(solrDocument.get("id")).get("item_title");String title = "";if (list != null && list.size() > 0) {title = list.get(0);} else {title = (String) solrDocument.get("item_title");}item.setTitle(title);//添加到商品列表itemList.add(item);}//把结果添加到SearchResult中result.setItemList(itemList);//返回return result;}
}

taotao-search-interface

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.taotao</groupId><artifactId>taotao-search</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>taotao-search-interface</artifactId><dependencies><dependency><groupId>com.taotao</groupId><artifactId>taotao-manager-pojo</artifactId><version>0.0.1-SNAPSHOT</version></dependency></dependencies>
</project>
package com.taotao.search.service;import com.taotao.common.pojo.SearchResult;public interface SearchService {SearchResult search(String queryString, int page, int rows) throws Exception;
}
package com.taotao.search.service;import com.taotao.common.pojo.TaotaoResult;public interface SearchItemService {TaotaoResult importItemsToIndex();
}

FastDFS,Redis,Solr,ActiveMQ核心技术整合一相关推荐

  1. B2C商城项目源码,基于Java开发的高可用分布式B2C商城系统,Java+Spring MVC+Dubbo+Zookeeper+MySQL+Redis+FastDFS+Nginx+Solr

    目录 前言 B2C商城-AIYOU 一.项目总体架构 二.系统软硬件设施总体规划 1.系统服务规划 2.应用服务规划 3.应用系统域名规划 三.系统运行环境构建 四.项目数据库创建 五.项目拉取 六. ...

  2. [Linux] linux下安装配置 zookeeper/redis/solr/tomcat/IK分词器 详细实例.

    今天 不知自己装的centos 出现了什么问题, 一直卡在 启动界面, 找了半天没找见原因(最后时刻还是发现原因, 只因自己手欠一怒之下将centos删除了, 而且选择的是在本地磁盘也删除. ..让我 ...

  3. 大型分布式redis+solr+Linux+nginx+springmvc+mybatis电商项目-任亮-专题视频课程

    大型分布式redis+solr+Linux+nginx+springmvc+mybatis电商项目-45845人已学习 课程介绍         中国移动省级网上商城项目,用于建立网上终端.营销案和号 ...

  4. Redis 7.0 核心技术、实战应用、面试题

    Redis 7.0 核心技术与实战应用

  5. FastDFS,Redis,Solr,ActiveMQ核心技术整合五

    02.商品分类选择-分析-前端js_ 03.商品分类选择-分析-数据库_ (JJTree渲染过程解析(parent_id为0就是父节点,is_parent为1说明下面有子节点,state1正常2删除. ...

  6. FastDFS,Redis,Solr,ActiveMQ核心技术整合二(1)

    02.商品分类选择-分析-前端js_ 03.商品分类选择-分析-数据库_ (JJTree渲染过程解析(parent_id为0就是父节点,is_parent为1说明下面有子节点,state1正常2删除. ...

  7. FastDFS,Redis,Solr,ActiveMQ核心技术整合三

    ioi 02.商品分类选择-分析-前端js_ 03.商品分类选择-分析-数据库_ (JJTree渲染过程解析(parent_id为0就是父节点,is_parent为1说明下面有子节点,state1正常 ...

  8. FastDFS,Redis,Solr,ActiveMQ核心技术整合二(2)

    02.商品分类选择-分析-前端js_ 03.商品分类选择-分析-数据库_ (JJTree渲染过程解析(parent_id为0就是父节点,is_parent为1说明下面有子节点,state1正常2删除. ...

  9. SSM框架整合一(springmvc+spring+mybatis+maven+tomcat)

    一,环境说明 jdk1.7.0_07(cmd命令行输入java -version查看),点击下载 eclipse Kepler Service Release 2 apache-maven-3.3.9 ...

最新文章

  1. R语言搭建炫酷的线上博客系统
  2. 简单的python抢红包脚本-Python自动抢红包,超详细教程,再也不会错过微信红包了!...
  3. 线程创建后,立刻调用CloseHandle的原因
  4. java运行构建期间出错_构建和运行Java 8支持
  5. 【数据结构与算法】哈夫曼树的Java实现
  6. ipv6地址_「案例」路由器怎么自动获取IPv6地址?
  7. kotlin和python哪个好_对比 Go 语言,Kotlin 有什么优势和劣势?
  8. 一文搞懂数据仓库分层模型
  9. centos 7 屏蔽国外ip访问
  10. python wow自动打怪脚本官方教程_【按键精灵】魔兽世界LR 自动打怪脚本
  11. php调用会员头像,phpcms v9模版如何调用会员头像_CMS系统建站教程
  12. dnf剑魂buff等级上限_DNF:心悦专区重新开放,道具及等级上限调整
  13. Windows实验——DNS劫持演练
  14. 如何使用python进行等额本金-等额本息贷款计算
  15. uniapp打包后高德地图定位失败解决
  16. 再补充三种内网穿透的方法:ngrok 、ngrok.cc、IOEE
  17. 英文版本Ubuntu下添加中文拼音输入法: Chinese (Intelligent Pinyin)
  18. linux cat命令,Linux cat命令使用方法详解
  19. 看漫画学python下载_漫画批量下载
  20. 一个阳光女孩儿的来信——网上答疑(21)

热门文章

  1. uniapp实现canvas画图
  2. 11.25 QLU校赛(2)
  3. linux清除文件内容 ,Linux清除文件内容的几种方法
  4. Android_获取手机IP和MAC地址
  5. 二次解析视屏 php,[PHP源码]最新PHP二次视频解析源码 带后台版/13092
  6. 软件测试应有的素质,高效测试人员应具有的7个品质
  7. html画布20等分,实现CSS等分布局的4种方式 - 小火柴的蓝色理想
  8. GBase 8c 产品运行环境
  9. 伤害世界服务器怎么注册手机版,伤害世界自己开服务器怎么开指令 | 手游网游页游攻略大全...
  10. MS SQL Server存储生僻字变为问号(?)的解决方法