⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writetag.java

📁 这是本人曾经在公司里用的,内部开发框架,基于struts+hibernate今天分享给大家
💻 JAVA
字号:
package cn.bway.struts.tag;

import javax.servlet.jsp.JspException;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;

/**
 * @author Kson
 *
 */
public class WriteTag extends org.apache.struts.taglib.bean.WriteTag {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String maxlength = null;

	public int doStartTag() throws JspException {

		if (ignore) {
			if (RequestUtils.lookup(pageContext, name, scope) == null)
				return (SKIP_BODY); // Nothing to output
		}

		Object value = RequestUtils.lookup(pageContext, name, property, scope);
		if (value == null)
			return (SKIP_BODY); // Nothing to output

		String output = null;

		if (maxlength != null) {
			output = formatValue(value);
			int outputLength = new Integer(maxlength).intValue();
			int stringLength = output.length();
			if (stringLength > outputLength) {
				output = output.substring(0, outputLength) + "..";
			}
		} else {
			output = formatValue(value);
		}

		// Print this property value to our output writer, suitably filtered
		if (filter)
			ResponseUtils.write(pageContext, ResponseUtils.filter(output));
		else
			ResponseUtils.write(pageContext, output);

		// Continue processing this page
		return (SKIP_BODY);

	}

	public String getMaxlength() {
		return maxlength;
	}

	public void setMaxlength(String maxlength) {
		this.maxlength = maxlength;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -