%2x java,JAVA-STRUTS-2x的项目配置

首先是web.xml的配置,这个是项目加载的开始。

1

2

3

4 struts2

5 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

6

7

8 struts2

9 *.do

10 *.jsp

11

12

13

14 index.jsp

15

然后是src下的struts.xml文件,它是struts配置文件的源头。

1 <?xml version="1.0" encoding="utf-8"?>

2 "-//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

15

16

17

18

19

20

21

22

23

24

25

26

27

加载主配置文件后,会加载子配置文件。这里就写出一个了,另一个可有可无,看项目结构了。

strutsxml/struts.xml

1 <?xml version="1.0" encoding="utf-8"?>

2 "-//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 /CategoriesList.jsp

11

12

13

子配置文件的action标签也可直接放到主配置文件中(package标签里)。

默认调用对应的java类中的execute方法。

com.junjuping.ui.action.Categories.java

1 public classCategories2 {3 public String execute() throwsException {4 String result = ""; //返回值

5 HttpServletRequest request =ServletActionContext.getRequest();6 HttpServletResponse response = ServletActionContext.getResponse();

7 CategoriesServce categoriesServce = newCategoriesServce();8 ArrayList resultList =categoriesServce.select();9 request.setAttribute("resultList", resultList);10 result = "succ";11 returnresult;12 }}

jsp文件在这里就不再说明了。

原文:http://www.cnblogs.com/junjuping/p/3794992.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值