Struts2 struts labels

Source: Internet
Author: User

Struts2 struts labels

1. index. jsp

 

Access attribute tags 

2. struts. xml

 

 

  
   
   
   
    
   
    /tags.jsp
      
  
 

3. tags. jsp

 

 

 
  1. Property:
  2. The property value is a string:
  3. Property default value:
  4. Property is set to HTML:
  5. Set sets the adminName value (the default value is request and ActionContext ):
  6. Set Value From request:
  7. Set Value From ActionContext:
  8. Set setting range:
  9. Value Range: <% = pagecontext. getattribute ("adminpassword") %>
  10. Set var, range: ActionContext:
  11. Use # values:
  12. Bean defines bean and uses param to set new property values;
  13. Bean:
  14. Include into de1.html include static English files
  15. Include include2.html include static Chinese files
  16. Include into de1.html contains static English files, meaning % usage
  17. If elseif else: age =
    Wrong age! Too young! Yeah!
    Null
  18. Traversal set:
  19. Custom variables:
  20. Use status:
    | Total number of elements that have been traversed: | Element indexes that have been traversed: | The current value is an even number? : | Is the current number odd? : | Is it the first element? : | Is it the last element? :

  21. |

  22. |

<% = Pagecontext. getattribute ("adminpassword") %> 4. TagsAction. java

 

 

package com.wxh.action;import com.opensymphony.xwork2.ActionSupport;public class TagsAction extends ActionSupport{private String password;private String username;public TagsAction(){}public String execute(){this.addFieldError("fielderror.test","wrong!");return SUCCESS;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}}

 

 

5. Dog. java

 

package com.wxh.action;public class Dog {public Dog(){}public Dog(String anme){super();this.name=name;}private String name;public String getName() {return name;}public void setName(String name) {this.name = name;}public String toString(){return "dog:"+name;}}

 

 

6. S. java

 

package com.wxh.action;public class S {public static String STR="STATIC STRING";public static String s(){return "static method";}}

7. User. java

 

 

package com.wxh.action;public class User {private int age;public User(){System.out.println("user.constructor!");}public User(int age){super();this.age=age;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public String toString(){return "user"+age;}}

8.include1.html

 

 

Include1.html 

9.20.de2.html

 

 

Chinese 


 

 


 

 

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.