`

写了一个struts2-number-plugin插件

阅读更多

为了格式化钱编辑框的格式,如保留后二位。Struts2没有提供相应的标签。struts1支持property的format属性。

于是自己写了一个关于数据格式化的插件。

在struts2包里的META-INF/struts-tags.tld

新增如下内容:

xml 代码
 <tag>
    <name>number</name>
    <tag-class>org.apache.struts2.views.jsp.ui.NumberTag</tag-class>
    <body-content>JSP</body-content>
    <description><![CDATA[Render an HTML input field of type number]]></description>
    <attribute>
      <name>accesskey</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html accesskey attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>cssClass</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[The css class to use for element]]></description>
    </attribute>
    <attribute>
      <name>cssStyle</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[The css style definitions for element ro use]]></description>
    </attribute>
    <attribute>
      <name>disabled</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html disabled attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>displayFormat</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[A pattern used for the visual display of the formatted number, e.g. ##.0#]]></description>
    </attribute>
    <attribute>
      <name>id</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[id for referencing element. For UI and form tags it will be used as HTML id attribute]]></description>
    </attribute>
    <attribute>
      <name>key</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the key (name, value, label) for this particular component]]></description>
    </attribute>
    <attribute>
      <name>label</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Label expression used for rendering a element specific label]]></description>
    </attribute>
    <attribute>
      <name>labelposition</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Define label position of form element (top/left)]]></description>
    </attribute>
    <attribute>
      <name>maxLength</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Deprecated. Use maxlength instead.]]></description>
    </attribute>
    <attribute>
      <name>maxlength</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[HTML maxlength attribute]]></description>
    </attribute>
    <attribute>
      <name>name</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[The name to set for element]]></description>
    </attribute>
    <attribute>
      <name>onblur</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[ Set the html onblur attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onchange</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onchange attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onclick</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onclick attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>ondblclick</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html ondblclick attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onfocus</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onfocus attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onkeydown</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onkeydown attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onkeypress</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onkeypress attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onkeyup</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onkeyup attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onmousedown</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onmousedown attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onmousemove</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onmousemove attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onmouseout</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onmouseout attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onmouseover</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onmouseover attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onmouseup</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onmouseup attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>onselect</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html onselect attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>readonly</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Whether the input is readonly]]></description>
    </attribute>
    <attribute>
      <name>required</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[If set to true, the rendered element will indicate that input is required]]></description>
    </attribute>
    <attribute>
      <name>requiredposition</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Define required position of required form element (left|right)]]></description>
    </attribute>
    <attribute>
      <name>size</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[HTML size attribute]]></description>
    </attribute>
    <attribute>
      <name>tabindex</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html tabindex attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>template</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[The template (other than default) to use for rendering the element]]></description>
    </attribute>
    <attribute>
      <name>templateDir</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[The template directory.]]></description>
    </attribute>
    <attribute>
      <name>theme</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[The theme (other than default) to use for rendering the element]]></description>
    </attribute>
    <attribute>
      <name>title</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the html title attribute on rendered html element]]></description>
    </attribute>
    <attribute>
      <name>tooltip</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the tooltip of this particular component]]></description>
    </attribute>
    <attribute>
      <name>tooltipConfig</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Set the tooltip configuration]]></description>
    </attribute>
    <attribute>
      <name>value</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description><![CDATA[Preset the value of input element.]]></description>
    </attribute>
  </tag>

struts2-number-plugin插件 

用法:与textfield几乎一模一样,只是多了一个displayFormat的属性,其格式取值例如:###.0#
  • struts2-number-plugin.jar (4.4 MB)
  • 描述: struts2-number-plugin,一个格式化数值的输入框格式插件
  • 下载次数: 64
分享到:
评论

相关推荐

    struts2-json-plugin-2.3.24-API文档-中文版.zip

    赠送jar包:struts2-json-plugin-2.3.24.jar; 赠送原API文档:struts2-json-plugin-2.3.24-javadoc.jar; 赠送源代码:struts2-json-plugin-2.3.24-sources.jar; 赠送Maven依赖信息文件:struts2-json-plugin-...

    struts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jar

    struts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jarstruts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jar

    struts2-struts1-plugin-2.1.6.jar

    struts2-struts1-plugin-2.1.6.jar

    struts2-ssl-plugin-1.2.1.jar

    struts2-ssl-plugin-1.2.1.jar

    struts2-json-plugin

    struts2-json-plugin,Struts JSON插件

    struts2-spring-plugin-2.3.4.jar

    Struts2-Spring-Plugin-2.3.4.jar 是一个专门为 Struts 2 框架和 Spring 框架整合而设计的插件,主要用于处理 Struts 2 和 Spring 之间的集成问题。在Java Web开发中,这两个框架经常一起使用,Spring 提供了依赖...

    struts2-struts1-plugin-2.1.8.1.jar

    最新struts2-struts1-plugin-2.1.8.1.jar

    struts2-dojo-plugin-2.2.1.jar

    Struts2-dojo-plugin-2.2.1.jar 是一个针对Apache Struts2框架的扩展插件,主要用于增强Struts2应用的用户界面交互性,特别是通过集成Dojo JavaScript库来提供丰富的AJAX功能和用户体验。这个插件是Struts2与Dojo ...

    Struts2-3.24集合jar

    struts2-config-browser-plugin-2.3.24.jar, struts2-core-2.3.24.jar, struts2-jasperreports-plugin-2.3.24.jar, struts2-jfreechart-plugin-2.3.24.jar, struts2-pell-multipart-plugin-2.3.24.jar, struts2-...

    struts2-dojo-plugin-2.3.4 jar

    struts2-dojo-plugin-2.3.4 jar 日期控件的jar包 需要的自行下载

    json-lib-2.1.jar和struts2-json-plugin-2.1.8.1.jar

    `struts2-json-plugin-2.1.8.1.jar` 则是Struts 2框架的一个插件,主要用于增强Struts 2对JSON的支持。Struts 2是一款非常流行的MVC(Model-View-Controller)框架,用于构建企业级的Java Web应用程序。这个插件允许...

    struts2-json-plugin-2.3.8.jar

    在实际开发中,为了使用这个插件,你需要将`struts2-json-plugin-2.3.8.jar`文件放入项目的类路径(classpath)下,然后在Struts2的配置文件(通常为struts.xml)中启用JSON插件。在Action类中,定义返回JSON数据的...

    struts2-number-plugin插件简单源代码

    Struts2-number-plugin插件是基于Apache Struts2框架的一个扩展,主要目的是为了方便开发者在Struts2应用中处理数字格式化和国际化的问题。这个插件提供了强大的功能,包括数字的格式化、货币转换以及百分比计算等。...

    struts2-spring-plugin-2.2.1.jar

    Struts2-Spring-Plugin-2.2.1.jar 是一个专门为 Struts2 框架与 Spring 框架集成而设计的插件。这个插件的主要目的是简化在基于Struts2的应用程序中整合Spring的功能,如依赖注入(DI)、AOP(面向切面编程)以及...

    struts2-convention-plugin-2.3.24.1

    struts2-convention-plugin-2.3.24.1

    struts2-plexus-plugin-2.1.6.jar

    struts2-plexus-plugin-2.1.6.jar

    struts2-config-browser-plugin-2.3.28-hjx20200915.jar

    默认的struts2-config-browser-plugin包中的ftl文件include标签路径用的相对路径,会找到包内的include文件,将包内ftl里include的路径改成的/开头的全路径。

Global site tag (gtag.js) - Google Analytics