首页 > 代码库 > struts2 通配符简化配置

struts2 通配符简化配置

在struts映射中重复出现的模式
动作方法描述下一个动作方法
add为save准备网页save
save提交INSERTlist
edit为update准备网页update
update提交UPDATElist
destroy为remove准备网页remove
remove提交DELETElist
show为详细展示准备网页list
list为列表展示准备网页list
print为打印准备网页list



一个动作类的DEMO:

package com.bankmetal.action;

public class DemoAction {
	
	
	public String add(){
		...
		return ADD;
	}
	
	public String save(){
		...
		return SAVE;
	}
	
	public String edit(){
		...
		return EDIT;
	}
	
	public String update(){
		...
		return UPDATE;
	}
	
	public String destroy(){
		...
		return DESTROY;
	}
	
	public String remove(){
		...
		return REMOVE;
	}
	
	public String show(){
		...
		return SHOW;
	}
	
	public String list(){
		...
		return LIST;
	}
	
	public String print(){
		...
		return PRINT;
	}
}



一个struts.xml的DEMO:

<action name="*-*" method="{2}" class="DemoAction">
	<result name="add">/pages/{1}/add.jsp</result>
	<result name="save">/pages/{1}/save.jsp</result>
	<result name="edit">/pages/{1}/edit.jsp</result>
	<result name="update">/pages/{1}/update.jsp</result>
	<result name="destroy">/pages/{1}/destroy.jsp</result>
	<result name="remove">/pages/{1}/remove.jsp</result>
	<result name="show">/pages/{1}/show.jsp</result>
	<result name="list">/pages/{1}/list.jsp</result>
	<result name="print">/pages/{1}/print.jsp</result>
</action>