struts2注解

web.xml配置

<filter>
  	<filter-name>struts2</filter-name>
  	<filter-class>
  		org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  	</filter-class>  	
  </filter>
  <filter-mapping>
  	<filter-name>struts2</filter-name>
  	<url-pattern>/*</url-pattern>
  </filter-mapping>

jar包:

1.commons-fileupload-1.2.2.jar 
2.commons-io-1.3.2.jar 
3.freemarker-2.3.15.jar 
4.ognl-3.0.1.jar 
5.struts2-convention-plugin-2.2.3.jar 
6.struts2-core-2.2.3.jar 
7.xwork-core-2.2.3.jar

struts.xml

<include file="struts/*.xml"></include>
	<constant name="struts.mapper.class"
		value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper" />
	<constant name="struts.mapper.prefixMapping" value="/p:rest,/s:rest,:struts" />
	<constant name="struts.rest.namespace" value="" />
	<!-- 指定控制器类的后缀为Controller -->
	<constant name="struts.convention.action.suffix" value="Controller" />
	<constant name="struts.convention.action.mapAllMatches" value="true" />
	<!-- 指定Action所在包继承的父包 -->
	<constant name="struts.convention.default.parent.package"
		value="rest-default" />

源文件实例:

@ResultPath("/")
@Results({@Result(name = "error", location = "/admin/error.jsp", type = "redirect"),
    @Result(name = "findInfo", location = "/admin/advert/listAdvert.jsp"),
    @Result(name = "addAdvert", location = "/admin/advert/addAdvert.jsp"),
    @Result(name = "modifyAdvert", location = "/admin/advert/addAdvert.jsp"),
    @Result(name = "result", location = "/admin/result.jsp"),})
public class AdvertAction extends BaseAction {
 
 @Action(value = "/admin/advert/find")//表单action属性=/admin/advert/find.action
    public String find(){
			return "findInfo";
		}


 @Action(value = "/admin/advert/add")
    public String add(){
    
			return "addAdvert";
		}
}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值