<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Struct2 标签</title>
<style type="css/text">
body{font-size:12px}
div{font-size:12px}
td{font-size:12px}
</style>
<link href="<s:url value="/webwork/jscalendar/calendar-blue.css" />" rel="stylesheet" type="text/css" media="all"/>
</head>
<body>
<div style="border: 1px solid #CCCCCC;width:350px;align:center" >
<s:form action="myTagAction!submit.action" method="post">
<s:checkbox name="chk" label="chk.." value="ab" title="选择"/>A
姓名<s:textfield name="fname" label="用记名" value="裴"/><br>
<s:checkboxlist list="chklist" name="selchk"/><br>
<s:combobox list="years" name="year" maxlength="2"></s:combobox><br>
<!-- <s:datepicker name="date" id="date" format="%Y-%m-%e"/><br>-->
<s:hidden name="vvname" value="hidden标签测试"/>
<s:label label="%{text('kk')}" name="kk"/><br>
<s:radio list="chklist" name="selchk"></s:radio><br>
<s:select list="citylist" name="city" listKey="local_net" listValue="city_name">
</s:select><br>
<s:textarea label="Comments" name="kk" cols="10" rows="3"/><br>
<s:submit value="提交"/>
</s:form>
</div>
</body>
</html>
Action代码
package one;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import domain.City;
import java.util.*;
public class TagAction extends ActionSupport {
private List citylist;
private String city;
private boolean chk;
private String fname;
private Map chklist;
private String selchk[];
private String year;
private List years;
private Date date;
private String vvname;
private String kk;
public String execute()throws Exception {
return this.SUCCESS;
}
public String submit()throws Exception{
System.out.println("chk="+chk);
System.out.println("city="+city);
System.out.println("fname="+fname);
System.out.println("selchk="+selchk.length);
for(int i=0;i<selchk.length;i++){
System.out.println(selchk[i]);
}
System.out.println("vvname="+vvname);
return this.INPUT;
}
public TagAction(){
citylist =new ArrayList();
citylist.add(new City("510","广州"));
citylist.add(new City("530","佛山"));
citylist.add(new City("550","深圳"));
chklist =new HashMap();
chklist.put("zh","中国");
chklist.put("en","美国");
chklist.put("eg","英国");
chklist.put("jp","日本");
years=new ArrayList();
years.add("2001");
years.add("2002");
years.add("2003");
years.add("2004");
years.add("2005");
years.add("2006");
}
public boolean isChk() {
return chk;
}
public void setChk(boolean chk) {
this.chk = chk;
}
public List getCitylist() {
return citylist;
}
public void setCitylist(List citylist) {
this.citylist = citylist;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String[] getSelchk() {
return selchk;
}
public void setSelchk(String[] selchk) {
this.selchk = selchk;
}
public Map getChklist() {
return chklist;
}
public void setChklist(Map chklist) {
this.chklist = chklist;
}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
public List getYears() {
return years;
}
public void setYears(List years) {
this.years = years;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getVvname() {
return vvname;
}
public void setVvname(String vvname) {
this.vvname = vvname;
}
public String getKk() {
return kk;
}
public void setKk(String kk) {
this.kk = kk;
}
}
<action name="myTagAction!*" method="{1}" class="one.TagAction">
<result name="input">/tag_1.jsp</result>
<result>/tag_1.jsp</result>
</action>
没有任何语言上的解析,详细文档,请参考:
http://www.blogjava.net/pdw2009/archive/2007/04/06/108935.html
posted on 2007-10-23 17:52
有猫相伴的日子 阅读(5973)
评论(3) 编辑 收藏 所属分类:
j2ee