博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

IT民工窝棚

有意思的事很多,有多少有意义的呢?
   qbq.cublog.cn
关于作者  
姓名:QBQ
职业:PG
年龄:25
位置:DL
个性介绍:有意思的事很多,有多少有意义的呢?

我的分类  




Struts2常用标签
这些都是Struts2的一些新标签,感觉很新鲜,特别是datetimedipacker标志感觉很好

filevalidateExample.jsp 文件
<%@ page language="java" contentType="text/html; charset=ISO-8859-5"
    pageEncoding
="ISO-8859-5"%>
<%@ 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>
<title>fieldValidatorsExample test</title>
<s:url id="siteCss" includeContext="true"
    value
="/validationExamplesStyles.css" />
<s:head theme="xhtml" />

</head>
<body>
<h3>All field Error will show</h3>
<s:fielderror />
<hr color="red" />

<s:form action="fieldValidators" method="post">
    
<s:textfield tooltip="ENTER YOUR NAME" label="YOUR NAME" name="name" />
    
<s:textfield tooltip="ENTER YOUR AGE" label="YOUR AGE" name="age" />

    
<s:datetimepicker tooltip="ENTER YOUR BIRTHDAY" label="YOUR BIRTHDAY"
        name
="birthday" />

    
<s:textfield tooltip="ENTER YOUR EMAIL" label="YOUR EMAIL" name="Email" />
    
<s:textfield tooltip="ENTER YOUR URL" label="YOUR URL" name="url" />

    
<s:select tooltip="SELECT YOUR PROGRAM" label="YOUR PROGRAM"
        name
="program" list="{'Java','.net','C#','Struts2'}" />

    
<s:checkboxlist tooltip="SELECT YOUR FAVOURITE COLOR"
        label
="FAVOURITE COLOR" name="color"
        list
="{'red','green','yellow','pink','blue'}" value="{'green','blue'}" />

    
<s:tree label="parent" id="parentId" theme="ajax"
        templateCssPath
="/struts/tree.css" showRootGrid="true" showGrid="true">
        
<s:treenode theme="ajax" label="child1" id="child1Id">
            
<s:treenode theme="ajax" label="grandchild1" id="grandchild1Id" />
            
<s:treenode theme="ajax" label="grandchild2" id="grandchild2Id" />
            
<s:treenode theme="ajax" label="grandchild3" id="grandchild3Id" />
        
</s:treenode>

        
<s:treenode theme="ajax" label="child2" id="child2Id" />
        
<s:treenode theme="ajax" label="child3" id="child3Id" />
        
<s:treenode theme="ajax" label="child4" id="child4Id" />
        
<s:treenode theme="ajax" label="child5" id="child5Id">
            
<s:treenode theme="ajax" label="gChild1" id="gChild1Id" />
            
<s:treenode theme="ajax" label="gChild2" id="gChild2Id" />
        
</s:treenode>
    
</s:tree>

    
<s:hidden name="hiddenName" value="bulktree and oakertree" />
    
<s:submit label="SUBMIT" />

</s:form>

</body>
</html>
FileValidateAction.java文件
package com.bulktree.struts2;

import java.util.Date;

import com.opensymphony.xwork2.ActionSupport;

public class FieldValidatorsAction extends ActionSupport {
    
private String name = null;
    
private Integer age = null;
    
private Date birthday = null;
    
private String Email = null;
    
private String url = null;
    
private String program = null;
    
private String color = null;
    
private String hiddenName = null;
    
private String child2 = null;
    
    
    
    
public String getChild2() {
        
return child2;
    }

    
public void setChild2(String child2) {
        
this.child2 = child2;
    }

    
public String getHiddenName() {
        
return hiddenName;
    }

    
public void setHiddenName(String hiddenName) {
        
this.hiddenName = hiddenName;
    }

    
public String getColor() {
        
return color;
    }

    
public void setColor(String color) {
        
this.color = color;
    }

    
public String getProgram() {
        
return program;
    }

    
public void setProgram(String program) {
        System.out.println(
"*****setProgram**********");
        
this.program = program;
    }

    
public String getName() {
        
return name;
    }

    
public void setName(String name) {
        
this.name = name;
    }

    
public Integer getAge() {
        
return age;
    }

    
public void setAge(Integer age) {
        
this.age = age;
    }

    
public Date getBirthday() {
        
return birthday;
    }

    
public void setBirthday(Date birthday) {
        
this.birthday = birthday;
    }

    
public String getEmail() {
        
return Email;
    }

    
public void setEmail(String email) {
        Email 
= email;
    }

    
public String getUrl() {
        
return url;
    }

    
public void setUrl(String url) {
        
this.url = url;
    }

    
    @Override
    
public String execute() throws Exception {
        
        
return SUCCESS;
    }

    
    @Override
    
public void validate() {
        
    }

    
    
    
}

struts.xml配置片段
<action name="fieldValidators"
            class
="com.bulktree.struts2.FieldValidatorsAction">
            
<result>/welcome.jsp</result>
        
</action>
welcome.jsp显示页面
<%@ page language="java" contentType="text/html; charset=GB2312"
    pageEncoding
="GB2312"%>
<%@ 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=GB2312">
<title>login</title>
</head>
<body>
YOUR USERNAME:
<FONT size="5" color="red"><s:property value="username" /></FONT>
<br>
YOUR PASSWORD:
<FONT size="5" color="red"><s:property value="password" /></FONT>
<br>

YOUR USERNAME:
<FONT size="5" color="red"><s:property value="user.username" /></FONT>
<br>
YOUR PASSWORD:
<FONT size="5" color="red"><s:property value="user.password" /></FONT>
<br>

YOUR NAME:
<FONT size="5" color="red"><s:property value="name" /></FONT>
<br>
YOUR AGE:
<FONT size="5" color="red"><s:property value="age" /></FONT>
<br>
YOUR BIRTHDAY:
<FONT size="5" color="red"><s:property value="birthday" /></FONT>
<br>
YOUR EMAIL:
<FONT size="5" color="red"><s:property value="Email" /></FONT>
<br>
YOUR URL:
<FONT size="5" color="red"><s:property value="url" /></FONT>
<br>
YOUR PROGARAM:
<FONT size="5" color="red"><s:property value="program" /></FONT>
<br>
YOUR FAVOURITE COLOR:
<FONT size="5" color="red"><s:property value="color" /></FONT>
<br>
YOUR HIDDEN NAME
<FONT size="5" color="red"><s:property value="hiddenName" /></FONT>
<br>

TREE:
<s:property value="child2" />

</body>
</html>

 发表于: 2008-05-07,修改于: 2008-05-07 14:31 已浏览77次,有评论1条 推荐 投诉

  网友评论
  xinyu391 时间:2008-05-12 11:43:56 IP地址:222.66.175.★
标签时用来看得 
你应该贴个效果图片 
光看代码,很枯燥


  发表评论



Copyright © 2001-2006 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们
页面生成时间:1.32351

京ICP证041476号