1.web.xml中配置拦截器
strutsFilter
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
strutsFilter
/*
2.·使用注解的方式配置struts需要引入一个jar包
3·action类的注解:
@ParentPackage("basePackage") //指定父包
@Namespace("/user") //指定命名空间
@Results( { @Result(name = "success", location = "/main.jsp")
@Result(name = "error", location = "/error.jsp") }) 全局的实现跳转的页面
@Action("userAction") //指定action的访问url
例如:java代码注解
1 package com.oracle.soccerleague.action;
……
22 @Namespace(value="/admin")
23 @ParentPackage(value="struts-default")
24 @Action(value="AddLeague")
25 @Results({
26 @Result(name="success", location="/admin/AddLeagueSucc.jsp"),
27 @Result(name="input", location="/admin/AddLeague.jsp")
28 })
29 public class AddLeagueAction extends ActionSupport {
30 private int year;
31 private String season;
32 private String title;
……
100 }
对应的struts.xml配置文件
以上注解与以下struts.xml配置作用相同:
6
7
8
9 class="com.oracle.soccerleague.action.AddLeagueAction">
10 /admin/AddLeagueSucc.jsp
11 /admin/AddLeague.jsp
12
13
14
4.struts.xml其他配置及作用