Use of the struts2 (s: number) Label

Source: Internet
Author: User

There are still a lot of materials on the Internet about the use of struts2 labels, but there is very little information about this number label. I don't know if it's too simple for anyone to write. I think this is still very useful. Write a few words.

Label definition file: struts-tags.tld under the struts2-core-x.x.x.jar package, excerpted the following definition:

     
  Render a formatted number.
      
  
   number
      
  
   org.apache.struts2.views.jsp.NumberTag
      
  
   empty
            
  The currency to use for a currency format
        
  
   currency
        
  
   false
        
  
   false
                
  Whether grouping is used
        
  
   groupingUsed
        
  
   false
        
  
   false
                
  Deprecated. Use 'var' instead
        
  
   id
        
  
   false
        
  
   false
                
  Maximum fraction digits
        
  
   maximumFractionDigits
        
  
   false
        
  
   false
                
  Maximum integer digits
        
  
   maximumIntegerDigits
        
  
   false
        
  
   false
                
  Minimum fraction digits
        
  
   minimumFractionDigits
        
  
   false
        
  
   false
                
  Maximum integer digits
        
  
   minimumIntegerDigits
        
  
   false
        
  
   false
                
  The number value to format
        
  
   name
        
  
   true
        
  
   false
                
  Parse integer only
        
  
   parseIntegerOnly
        
  
   false
        
  
   false
                
  The rounding mode to use - not implemented yet as this required Java 1.6
        
  
   roundingMode
        
  
   false
        
  
   false
                
  Type of number formatter (currency, integer, number or percent, default is number)
        
  
   type
        
  
   false
        
  
   false
                
  Name used to reference the value pushed into the Value Stack
        
  
   var
        
  
   false
        
  
   false
          
  
   false
    
 

If you are interested, find the source code of the org. apache. struts2.views. jsp. NumberTag class below.

Write an example to make it clear:

Action class:

package test.action;import java.util.ArrayList;import java.util.List;import test.model.User;import com.opensymphony.xwork2.ActionSupport;public class TestAction extends ActionSupport {private static final long serialVersionUID = 2752911709036089235L;private int num;private List
 
   userList;public String testNumber(){num = 56466126;userList = new ArrayList
  
   ();userList.add(new User("Mike",4546645));userList.add(new User("Sam",2389469));userList.add(new User("Keven",8923741));return SUCCESS;}//getter and setterpublic int getNum() {return num;}public void setNum(int num) {this.num = num;}public List
   
     getUserList() {return userList;}public void setUserList(List
    
      userList) {this.userList = userList;}}
    
   
  
 

User. java

package test.model;public class User {private String name;private int salary;public User(){}public User(String name,int salary){this.name = name;this.salary = salary;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getSalary() {return salary;}public void setSalary(int salary) {this.salary = salary;}}

JSP: number. jsp

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









Struts. xml

 
  /number.jsp
 

Other attributes of the tag:


That's all.









Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.