当前位置:首页 > 科技 >

Struts2 struts标签介绍

发布时间:2017-09-05 11:26:26

Struts2 struts标签介绍

1.index.jsp

访问属性 tags
2.struts.xml /tags.jsp
3.tags.jsp

property:

property 取值为字符串:

property 设定默认值:

property 设定为HTML:

set 设定adminName值(默认为request和ActionContext):

set 从request取值:

set 从ActionContext取值:

set 设定范围:

从相应的范围取值:

set 设定var,范围为ActionContext:

使用#取值:

bean 定义bean,并使用param来设定新的属性值;

bean查看debug情况:

include include1.html 包含静态英文文件

include include2.html 包含静态中文文件

include include1.html 包含静态英文文件,说明%用法

if elseif else: age=
wrong age! too young! yeah!
null

遍历集合:

自定义变量:

使用status:
| 遍历过得元素总数:| 遍历过得元素索引:| 当前是偶数?:| 当前是奇数?:| 是第一个元素吗?:| 是最后一个元素吗?:


|


|


4.TagsAction.java package com.wxh.action; import com.opensymphony.xwork2.ActionSupport; public class TagsAction extends ActionSupport{ private String password; private String username; public TagsAction(){ } public String execute(){ this.addFieldError("fielderror.test","wrong!"); return SUCCESS; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } } 5.Dog.java package com.wxh.action; public class Dog { public Dog(){ } public Dog(String anme){ super(); this.name=name; } private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public String toString(){ return "dog:"+name; } } 6.S.java package com.wxh.action; public class S { public static String STR="STATIC STRING"; public static String s(){ return "static method"; } }
7.User.java package com.wxh.action; public class User { private int age; public User(){ System.out.println("user.constructor!"); } public User(int age){ super(); this.age=age; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String toString(){ return "user"+age; } }
8.include1.html include1.html
9.include2.html 中文


企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:神农架SEO http://shennongjia.4567w.com