1、web.xml里面不能設置為*.do struts2已經廢除.do后綴名,否則無論怎樣都訪問不到頁面404錯
struts.xml文件內容如下:

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

2、如果在類上面注解比如(假如包含兩個方法,并且要返回視圖,如果不需要返回視圖這里即可不用填寫任何注解):
@ResultPath("/WEB-INF/jsp")
@Results( {
@Result(name = "success", location = "Poc_test.jsp", type = "dispatcher"),
@Result(name="success",location="Poc_test.jsp",type="dispatcher")})
public class XdsAction extends ActionSupport implements ModelDriven<Ris>{
......
}
那么頁面進行訪問的鏈接要按照如下約定:(方法名字即為頁面要訪問的url)
http://localhost:8080/web/xds!方法名
里面的xds表示類名字,如果類名為XdsAction那么要去掉Action并且將首寫字母小寫然后進行訪問
2、如果在方法上面注解:
@Action(value="/welcome",results={@Result(location="/WEB-INF/jsp/Poc_test.jsp",type="dispatcher",name="success")})
public String welcome(){
return "success";
}
頁面上直接訪問http://localhost:8080/web/welcome即可
進行模塊化開發便于統一管理,建議使用類上面注解的方式,方法名即為頁面訪問名字
3、使用struts2后通過request.getInputStream()方法獲取的InputStream流無法獲取HTTP請求正文,這是因為struts2攔截器進行了攔截,并且request的content-type設置成了application/x-www-form-urlencoded,在struts2中要求對content-type進行設置,改成text/html即可。如果單純使用servlet則沒有這種限制。