commons-collections-3.1.jar
commons-configuration-1.2.jar
commons-lang.jar
commons-logging.jar
1
public class TankAndkCardPlugIn implements PlugIn
{
2
3
public Map<String, Object> tankMap;
4
5
public void destroy()
{
6
7
}
8
9
10
public void init(ActionServlet actionServlet, ModuleConfig moduleConfig)
11
throws ServletException
{
12
13
ServletContext application = actionServlet.getServletContext();
14
15
//讀取tankshop.xml
16
try
{
17
18
URL url = Thread.currentThread().getContextClassLoader().getResource("tankshop.xml");
19
20
XMLConfiguration configuration = new XMLConfiguration(url);
21
22
List idList = configuration.getList("Table.Row.id");
23
List nameList = configuration.getList("Table.Row.name");
24
List picList = configuration.getList("Table.Row.picture");
25
List infoList = configuration.getList("Table.Row.info");
26
27
tankMap = new HashMap<String, Object>();
28
29
//解析xml
30
for(int i=0;i<nameList.size();i++)
{
31
32
String id = (String)idList.get(i);
33
String name = (String)nameList.get(i);
34
String pic = (String)picList.get(i);
35
String info = (String)infoList.get(i);
36
37
TankAndCardObjbean bean = new TankAndCardObjbean();
38
39
bean.setId(id);
40
bean.setName(name);
41
bean.setPicture(pic);
42
bean.setInfo(info);
43
44
tankMap.put(id+"", bean);
45
46
}
47
48
application.setAttribute("tankMap",tankMap);
49
50
System.out.println("tankMap ok!!!!!!!!!!!!!!!!!!!!!");
51
52
} catch (Exception e)
{
53
54
System.out.println("tankMap error************************");
55
}
56
57
58
}
59
60
}
61
62



2

3

4

5



6

7

8

9

10

11



12

13

14

15

16



17

18

19

20

21

22

23

24

25

26

27

28

29

30



31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52



53

54

55

56

57

58

59

60

61

62
