`

自定义struts2 tag

 
阅读更多

 

添加Bean对象

 

 

package com.show.tag.input;

import org.apache.struts2.components.Component;

import com.opensymphony.xwork2.util.ValueStack;

/**
 * 
 * @author liuqing
 * 基础Tag类
 *
 */
public class HtmlInput extends Component {
	
	private String theme;
	
	private String id;
	
	private String width;
	
	private String height;
	
	private String name;
	
	private String cssStyle;
	
	private String value;
	
    private boolean isNumber;
	
	private int min;
	
	private int max;
	
	private int precision;
	
	private int minLength;
	
	private int maxLength;
	
	private boolean isString;
	
	private String onchange;

	public HtmlInput(ValueStack stack) {
		super(stack);
	}

	public HtmlInput(ValueStack stack, String width, String height,
			String name, String cssStyle) {
		super(stack);
		this.width = width;
		this.height = height;
		this.name = name;
		this.cssStyle = cssStyle;
	}
	
	public HtmlInput(ValueStack stack, String id, String width, String height,
			String name, String cssStyle, String value) {
		super(stack);
		this.id = id;
		this.width = width;
		this.height = height;
		this.name = name;
		this.cssStyle = cssStyle;
		this.value = value;
	}

	public HtmlInput(ValueStack stack, String theme, String id, String width,
			String height, String name, String cssStyle, String value) {
		super(stack);
		this.theme = theme;
		this.id = id;
		this.width = width;
		this.height = height;
		this.name = name;
		this.cssStyle = cssStyle;
		this.value = value;
	}

	/**
	 * @return the width
	 */
	public String getWidth() {
		return width;
	}

	/**
	 * @param width the width to set
	 */
	public void setWidth(String width) {
		this.width = width;
	}

	/**
	 * @return the height
	 */
	public String getHeight() {
		return height;
	}

	/**
	 * @param height the height to set
	 */
	public void setHeight(String height) {
		this.height = height;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the cssStyle
	 */
	public String getCssStyle() {
		return cssStyle;
	}

	/**
	 * @param cssStyle the cssStyle to set
	 */
	public void setCssStyle(String cssStyle) {
		this.cssStyle = cssStyle;
	}


	/**
	 * @return the value
	 */
	public String getValue() {
		return value;
	}


	/**
	 * @param value the value to set
	 */
	public void setValue(String value) {
		this.value = value;
	}


	/**
	 * @return the id
	 */
	public String getId() {
		if (this.id == null || "".equals(id)) {
			this.id = this.name;
		}
		return id;
	}


	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}


	/**
	 * @return the theme
	 */
	public String getTheme() {
		return theme;
	}


	/**
	 * @param theme the theme to set
	 */
	public void setTheme(String theme) {
		this.theme = theme;
	}

	/**
	 * @return the isNumber
	 */
	public boolean isNumber() {
		return isNumber;
	}

	/**
	 * @param isNumber the isNumber to set
	 */
	public void setNumber(boolean isNumber) {
		this.isNumber = isNumber;
	}

	/**
	 * @return the min
	 */
	public int getMin() {
		return min;
	}

	/**
	 * @param min the min to set
	 */
	public void setMin(int min) {
		this.min = min;
	}

	/**
	 * @return the max
	 */
	public int getMax() {
		return max;
	}

	/**
	 * @param max the max to set
	 */
	public void setMax(int max) {
		this.max = max;
	}

	/**
	 * @return the precision
	 */
	public int getPrecision() {
		return precision;
	}

	/**
	 * @param precision the precision to set
	 */
	public void setPrecision(int precision) {
		this.precision = precision;
	}

	/**
	 * @return the minLength
	 */
	public int getMinLength() {
		return minLength;
	}

	/**
	 * @param minLength the minLength to set
	 */
	public void setMinLength(int minLength) {
		this.minLength = minLength;
	}

	/**
	 * @return the maxLength
	 */
	public int getMaxLength() {
		return maxLength;
	}

	/**
	 * @param maxLength the maxLength to set
	 */
	public void setMaxLength(int maxLength) {
		this.maxLength = maxLength;
	}

	/**
	 * @return the isString
	 */
	public boolean isString() {
		return isString;
	}

	/**
	 * @param isString the isString to set
	 */
	public void setString(boolean isString) {
		this.isString = isString;
	}

	/**
	 * @return the onchange
	 */
	public String getOnchange() {
		return onchange;
	}

	/**
	 * @param onchange the onchange to set
	 */
	public void setOnchange(String onchange) {
		this.onchange = onchange;
	}
	
}
 

 

 

 

package com.show.tag.input;

import java.io.IOException;
import java.io.Writer;

import com.opensymphony.xwork2.util.ValueStack;

/**
 * 
 * @author liuqing
 * @version 1.0
 * 2011-8-24
 *
 */
public class DateBox extends HtmlInput {
	
	private String theme;
	
	private int inputNumber;
	
	private String match;
	
	private String split;
	
	private String align;
	
	
	public DateBox(ValueStack stack, String id,String width,String height,
			String name,String cssStyle,String value,int inputNumber, String match,
			String split, String align,String theme,boolean isNumber,int min
			,int max,int precision,int minLength,int maxLength,boolean isString
			,String onchange) {
		super(stack,id,width,height,name,cssStyle,value);
		this.inputNumber = inputNumber;
		this.match = match;
		this.split = split;
		this.align = align;
		this.theme = theme;
		this.setNumber(isNumber);
		this.setMin(min);
		this.setMax(max);
		this.setPrecision(precision);
		this.setMinLength(minLength);
		this.setMaxLength(maxLength);
		this.setString(isString);
		this.setOnchange(onchange);
	}

	public DateBox(ValueStack stack) {
		super(stack);
	}

	/* (non-Javadoc)
	 * @see org.apache.struts2.components.Component#start(java.io.Writer)
	 */
	@Override
	public boolean start(Writer writer) {
		StringBuffer buf = new StringBuffer("<div style=\"margin:2px;text-align:" +
				this.align +
				";\"><input name=\"");
		buf.append(this.getName())
		.append("\" type=\"text\" class=\"easyui-datebox\" ")
		.append("style=\"width:").append(width(this.getWidth())).append("px;")
		.append(" height:").append(height(this.getHeight())).append("px;");
		String stackValue = stack.findString(this.getName());
		buf.append(this.getCssStyle()).append("\" ");
		if (stackValue != null && !"".equals(stackValue)
				//&& (this.getValue() == null || "".equals(this.getValue()))
				) {
			buf.append(" value=\"").append(stackValue).append(" \" />");
		}
		else {
			buf.append(" value=\"").append(this.getValue()).append("\" />");
		}
		try {
			writer.write(buf.toString());
			writer.flush();
		} 
		catch (IOException e) {
			e.printStackTrace();
		}
		return super.start(writer);
	}



	/**
	 * @return the inputNumber
	 */
	public int getInputNumber() {
		return inputNumber;
	}

	/**
	 * @param inputNumber the inputNumber to set
	 */
	public void setInputNumber(int inputNumber) {
		this.inputNumber = inputNumber;
	}

	/**
	 * @return the match
	 */
	public String getMatch() {
		return match;
	}

	/**
	 * @param match the match to set
	 */
	public void setMatch(String match) {
		this.match = match;
	}

	/**
	 * @return the split
	 */
	public String getSplit() {
		return split;
	}

	/**
	 * @param split the split to set
	 */
	public void setSplit(String split) {
		this.split = split;
	}

	/**
	 * @return the align
	 */
	public String getAlign() {
		return align;
	}

	/**
	 * @param align the align to set
	 */
	public void setAlign(String align) {
		this.align = align;
	}

	/**
	 * @return the theme
	 */
	public String getTheme() {
		return theme;
	}

	/**
	 * @param theme the theme to set
	 */
	public void setTheme(String theme) {
		this.theme = theme;
	}
	
	private String width(String value) {
		if (value == null || "".equals(value) 
				|| value.length() == 0) {
			return "160";
		}
		return value;
	}
	private String height(String value) {
		if (value == null || "".equals(value) 
				|| value.length() == 0) {
			return "26";
		}
		return value;
	}
	
}
 

step 2:添加Tag 类注意struts2 valueStack

 

package com.show.tag.input;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ComponentTagSupport;

import com.opensymphony.xwork2.util.ValueStack;

/**
 * 
 * @author liuqing
 *
 */
public class DateBoxTag extends ComponentTagSupport {
	
    private String width = "";
	
	private String height = "";
	
	private String name = "";
	
	private String cssStyle = "";
	
	private String value = "";
	
    private boolean isNumber;
		
	private int min;
	
	private int max;
	
	private int precision;
	
	private int minLength;
	
	private int maxLength;
	
	private boolean isString;
	
	private String align = "";

	@Override
	public Component getBean(ValueStack value, HttpServletRequest request,
			HttpServletResponse response) {
		DateBox box = new DateBox(value);
		box.setWidth(width);
		box.setHeight(height);
		box.setName(name);
		box.setCssStyle(cssStyle);
		box.setValue(this.value);
		box.setAlign(align);
		return box;
	}

	/**
	 * @return the width
	 */
	public String getWidth() {
		return width;
	}

	/**
	 * @param width the width to set
	 */
	public void setWidth(String width) {
		this.width = width;
	}

	/**
	 * @return the height
	 */
	public String getHeight() {
		return height;
	}

	/**
	 * @param height the height to set
	 */
	public void setHeight(String height) {
		this.height = height;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the cssStyle
	 */
	public String getCssStyle() {
		return cssStyle;
	}

	/**
	 * @param cssStyle the cssStyle to set
	 */
	public void setCssStyle(String cssStyle) {
		this.cssStyle = cssStyle;
	}

	/**
	 * @return the value
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * @return the isNumber
	 */
	public boolean isNumber() {
		return isNumber;
	}

	/**
	 * @param isNumber the isNumber to set
	 */
	public void setNumber(boolean isNumber) {
		this.isNumber = isNumber;
	}

	/**
	 * @return the min
	 */
	public int getMin() {
		return min;
	}

	/**
	 * @param min the min to set
	 */
	public void setMin(int min) {
		this.min = min;
	}

	/**
	 * @return the max
	 */
	public int getMax() {
		return max;
	}

	/**
	 * @param max the max to set
	 */
	public void setMax(int max) {
		this.max = max;
	}

	/**
	 * @return the precision
	 */
	public int getPrecision() {
		return precision;
	}

	/**
	 * @param precision the precision to set
	 */
	public void setPrecision(int precision) {
		this.precision = precision;
	}

	/**
	 * @return the minLength
	 */
	public int getMinLength() {
		return minLength;
	}

	/**
	 * @param minLength the minLength to set
	 */
	public void setMinLength(int minLength) {
		this.minLength = minLength;
	}

	/**
	 * @return the maxLength
	 */
	public int getMaxLength() {
		return maxLength;
	}

	/**
	 * @param maxLength the maxLength to set
	 */
	public void setMaxLength(int maxLength) {
		this.maxLength = maxLength;
	}

	/**
	 * @return the isString
	 */
	public boolean isString() {
		return isString;
	}

	/**
	 * @param isString the isString to set
	 */
	public void setString(boolean isString) {
		this.isString = isString;
	}

	/**
	 * @return the align
	 */
	public String getAlign() {
		return align;
	}

	/**
	 * @param align the align to set
	 */
	public void setAlign(String align) {
		this.align = align;
	}
	
}
 

 

 step 3 写tld 文件

 

  <?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
    <tlib-version>2.2.3</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>tangs</short-name>
    <uri>/struts-tags-zk</uri>
    <display-name>"Tangs Tags"</display-name>
    <tag>
        <name>toolbar</name>
        <tag-class>com.show.toolbar.OperationTag</tag-class>
        <body-content>JSP</body-content>
        <attribute>
            <name>addOnclick</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>addHref</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>saveOnclick</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>saveHref</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>removeOnclick</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>removeHref</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>printOnclick</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>printHref</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>searchOnclick</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>searchHref</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>backOnclick</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>backHref</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
    </tag>
    <tag>
        <name>inputUnderline</name>
        <tag-class>com.show.tag.input.UnderLineTag</tag-class>
        <body-content>JSP</body-content>
        <attribute>
            <name>name</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>width</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>height</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>cssStyle</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>value</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
    </tag>
    
    <tag>
        <name>inputNoneLine</name>
        <tag-class>com.show.tag.input.NoneLineTag</tag-class>
        <body-content>JSP</body-content>
        <attribute>
            <name>name</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>width</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>height</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>cssStyle</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>value</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
    </tag>
    
    <tag>
        <name>dateBox</name>
        <tag-class>com.show.tag.input.DateBoxTag</tag-class>
        <body-content>JSP</body-content>
        <attribute>
            <name>name</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>width</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>height</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>cssStyle</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>value</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>align</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
    </tag>
    
    <tag>
        <name>datetimeBox</name>
        <tag-class>com.show.tag.input.DatetimeBoxTag</tag-class>
        <body-content>JSP</body-content>
        <attribute>
            <name>name</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>width</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>height</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>cssStyle</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>value</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>align</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
    </tag>
    
    <tag>
        <name>inputList</name>
        <tag-class>com.show.tag.input.ListInputTag</tag-class>
        <body-content>JSP</body-content>
        <attribute>
            <name>id</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>name</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>width</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>height</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>cssStyle</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>value</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>align</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>inputNumber</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>match</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>split</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>theme</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>useNumber</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>min</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>max</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>precision</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>minLength</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>maxLength</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>useString</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>onchange</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
    </tag>
    
    <tag>
        <name>textArea</name>
        <tag-class>com.show.tag.input.TextAreaInputTag</tag-class>
        <body-content>JSP</body-content>
        <attribute>
            <name>id</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>name</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>width</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        
        <attribute>
            <name>height</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>cssStyle</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>value</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>align</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>match</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>split</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>theme</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>useNumber</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>min</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>max</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>precision</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>minLength</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>maxLength</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>useString</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
        <attribute>
            <name>useBorder</name>
            <required>false</required>
            <rtexprvalue>false</rtexprvalue>
        </attribute>
    </tag>
    
    
</taglib>
 

  <%@taglib prefix="sx" uri="/struts-tags-zk" %>

 

 <sx:dateBox width="300" align="right" name="startDate" />

  

 OK

 

 

  • 大小: 2.2 KB
分享到:
评论

相关推荐

    自定义struts2标签

    首先,自定义Struts2标签的本质是创建一个与JSP标签库(Tag Library)相关的Java类。这个类需要继承自Struts2提供的`com.opensymphony.xwork2.util.CompoundRoot`或`org.apache.struts2.views.jsp.TagSupport`基类,...

    struts2 自定义标签

    在Struts2中,自定义标签是提高代码可读性和可维护性的重要工具。本文将深入探讨Struts2自定义标签的实现机制、优点以及如何在实际项目中进行应用。 一、Struts2自定义标签的概念 自定义标签是JSP的一种扩展,允许...

    自定义struts2 分页标签

    本教程将详细介绍如何在Struts2中自定义分页标签。 在传统的网页开发中,分页通常通过服务器端脚本或JavaScript实现,但在Struts2框架中,我们可以创建自定义标签来完成这一任务,使得代码更加模块化和易于维护。...

    tag struts2的自定义标签实例

    在Struts2框架中,自定义标签是扩展和优化应用功能的重要手段,它允许开发者创建符合业务逻辑且可重用的视图组件。本实例将深入探讨如何在Struts2中实现自定义标签,以及其背后的原理和步骤。 首先,自定义标签在...

    基于struts2 自定义标签 分页

    自定义标签是Struts2的一个重要特性,允许开发者扩展框架的功能,提供更友好的界面元素。在这个基于Struts2的自定义分页标签的实践中,我们将深入探讨如何创建、配置和使用自定义标签来实现数据的分页展示,同时与...

    Struts2自定义标签

    2. **编写标签处理类(Tag Handler Class)**:这个类继承自Struts2提供的`org.apache.struts2.views.jsp.ui.TagSupport`或`org.apache.struts2.views.jsp.ComponentTagSupport`基类,实现标签的具体逻辑。...

    struts2自定义标签案例详解

    在Struts2中,自定义标签的实现是提升可重用性和简化视图层代码的一个重要特性。下面我们将深入探讨如何在Struts2中实现自定义标签,以及其背后的原理。 自定义标签的创建主要涉及以下三个步骤: 1. **创建taglib...

    自定义Struts

    **自定义Struts**是一种基于Java的技术,用于构建企业级Web应用程序。在传统的JSP(JavaServer Pages)和Servlet开发中,代码往往混杂在视图层和控制层,这不利于项目的维护和扩展。Struts框架就是为了克服这些局限...

    Struts2 自定义下拉框标签Tag(源码)

    自定义标签主要包括三个步骤: 1、编写java类,继承TagSupport类; 2、创建tld文件,影射标签名和标签的java类; 3、jsp页面引入tld。 博文地址:http://blog.csdn.net/itmyhome1990/article/details/50718282

    自定义Tag标签的使用、Struts2国际化全局资源配置(老鸟请绕道)

    在Struts2中,我们可以继承`org.apache.struts2.views.jsp.TagSupport`或`org.apache.struts2.views.jsp.ui.Tag`基类,然后覆盖相应的方法来定义自定义行为。 例如,假设我们要创建一个显示用户信息的自定义标签`...

    struts实现自定义标签

    在 Struts 中,我们可以通过实现 `org.apache.struts.taglib.Tag` 接口来创建自定义标签。 二、创建自定义标签库 1. 创建 Tag 类:首先,我们需要创建一个 Java 类,该类继承自 `org.apache.struts.taglib.Tag` 或...

    Struts2 自定义标签

    在Struts2中,自定义标签是开发者扩展框架功能和简化视图层编码的重要手段。自定义标签允许将复杂的逻辑封装到可重用的组件中,提高代码的可读性和可维护性。 在Struts2中创建自定义标签,通常涉及以下几个步骤: ...

    struts2 tag 使用实例

    Struts2标签库是Struts2框架的一部分,它提供了一系列的HTML、逻辑和...总的来说,Struts2标签库是Struts2框架的一大特色,它极大地简化了MVC模式下的视图层开发,使得开发人员更加专注于业务逻辑,而非页面呈现细节。

    留言板留言板struts2留言板struts2

    拦截器链是Struts2的一大特色,允许开发者自定义拦截器,实现如权限验证、日志记录、事务管理等功能。 4. **结果类型(Result)**:Action执行完成后,会返回一个结果类型,告诉框架如何处理后续的响应。Struts2内置...

    Struts2_自定义标签的方法

    ### Struts2自定义标签详解 #### 一、引言 在Web开发中,Struts2框架...总之,Struts2自定义标签的实现涉及UIBean、JSP Tag和Template三个关键组成部分,通过合理的规划和设计,可以极大地方便Web应用的开发和维护。

    struts2的自定义标签例子

    下面将详细探讨如何在Struts2中创建和使用自定义标签。 首先,自定义标签是JSP标准标签库(JSTL)的扩展,允许我们定义自己的标签来简化页面编码。在Struts2中,自定义标签通常通过Action类和结果视图来与后台业务...

Global site tag (gtag.js) - Google Analytics