spring+hibernate+struts2+compass整合(三)

2014-11-24 07:34:31 · 作者: · 浏览: 5
"name:" + queryString).toQuery().hits();
44 System.out.println("queryString:" + queryString);
45 System.out.println("hits:" + hits.getLength());
46 for (int i = 0; i < hits.length(); i++) {
47 Product hit = (Product) hits.data(i);
48 list.add(hit);
49 }
50
51 return list;
52 }
53
54 public CompassTemplate getCompassTemplate() {
55 return compassTemplate;
56 }
57
58 }

/compass1/src/paoding-dic-home.properties
paoding.dic.home=C:/paoding/dic
paoding.dic.detector.interval=60

/compass1/src/struts.xml
1 < xml version="1.0" encoding="UTF-8" >
2 3 "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
4 "http://struts.apache.org/dtds/struts-2.0.dtd">
5
6
7
8
9
10
11
12
13
14 insertOk.jsp
15

16
17 searchResults.jsp
18

19
20
21

22
23
24
25
26

/compass1/WebRoot/product/input.jsp
1 <%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8"%>
3 <%@ taglib prefix="s" uri="/struts-tags"%>
4 http://www.w3.org/TR/html4/loose.dtd">
5
6
7
8
9
10 添加信息
11
12
13


14
15
16
17
18
19
20
21
22
54
55
56
添加商品名称

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
45
46
47
49
51
52
商品名称
商品品牌
商品价格
商品描述
44
 
48

50

53

57

58

59
60

/compass1/WebRoot/product/insertOk.jsp
1 <%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8"%>
3 http://www.w3.org/TR/html4/loose.dtd">
4
5
6
7 Insert title here
8
9
10 添加商品成功!
11
12
13

/compass1/WebRoot/product/search.jsp
1 <%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8"%>
3 <%@taglib prefix="s" uri="/struts-tags" %>
4
5 http://www.w3.org/TR/html4/loose.dtd">
6
7
8
9 Insert title here
10
11
12
13
14
15

16
17
18
19

/compass1/WebRoot/product/searchResults.jsp
1 <%@ page language="java" contentType="text/html; charset=UTF-8"
2 import="java.util.List"
3 pageEncoding="UTF-8"%>
4 <%@taglib prefix="s" uri="/struts-tags" %>
5
6 http://www.w3.org/TR/html4/loose.dtd">
7
8
9
10 Insert title here
11
12
13 <%
14
15 if(((List)request.getAttribute("searchresults")).size()==0){
16 %>
17 no results found.
18 <%} %>
19
20


21
22

25
28
31
34
35
36

23
24

26
27

29
30

32
33

37
38
39

/compass1/WebRoot/WEB-INF/applicationContext-compass.xml
1 < xml version="1.0" encoding="UTF-8" >
2
3 http://www.springframework.org/schema/beans"
4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5 xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
6 default-lazy-init="true">
7
8
9 10 class="org.compass.annotations.config.CompassAnnotationsConfiguration">
11

12
13
14
15
16
17 classpath:com/v512
18

19

20
21 /lucene/indexes
22

23
24
25
26
27 com.v512.example.model.Product
28

29

30 31 ref="annotationConfiguration" />
32
33
34
35
36 org.compass.spring.transaction.SpringSyncTransactionFactory
37

38 net.paoding.analysis.analyzer.PaodingAnalyzer
39

40

41
42
43

44
45
46 47 class="org.compass.gps.device.hibernate.HibernateGpsDevice">
48
49 hibernateDevice
50

51
52
53 true
54

55