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

📄 writetag.java

📁 struts+spring+hibernate自创框架
💻 JAVA
字号:
package com.pegasus.framework.component.taglib.html;

import org.apache.struts.taglib.TagUtils;

import javax.servlet.jsp.JspException;

public class WriteTag extends org.apache.struts.taglib.bean.WriteTag {
    protected String propertyName = null;
    protected int length = -1;
    /**
     * @return .
     */
    public String getPropertyName() {
        return propertyName;
    }

    /**
     * @param propertyName .
     */
    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName;
    }

    /**
     *
     * @return   .
     */
    public int getLength() {
        return length;
    }

    /**
     *
     * @param length  .
     */
    public void setLength(int length) {
        this.length = length;
    }

    /**
     * Process the start tag.
     *
     * @return .
     * @throws JspException if a JSP exception has occurred
     */
    public int doStartTag() throws JspException {

        // Look up the requested bean (if necessary)
        if (ignore) {
            if (TagUtils.getInstance().lookup(pageContext, name, scope) == null) {
                return (SKIP_BODY); // Nothing to output
            }
        }
        if (propertyName != null)
            property = (String) TagUtils.getInstance().lookup(pageContext, propertyName, property, scope);

        // Look up the requested property value
        Object value = TagUtils.getInstance().lookup(pageContext, name, property, scope);

        if (value == null) {
            return (SKIP_BODY); // Nothing to output
        }

        // Convert value to the String with some formatting
        String output = formatValue(value);
        //Forever add for left string
        if(length >0 ){
            if(output.length()>length)
                output = output.substring(0,length)+"...";
        }

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

        // Continue processing this page
        return (SKIP_BODY);

    }

    /**
     * Release all allocated resources.
     */
    public void release() {

        super.release();
        propertyName = null;
        length = -1;
    }
}

⌨️ 快捷键说明

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