In struts2 development, some functions need to be configured in struts. xml

Source: Internet
Author: User

In struts2 development, some functions need to be configured in struts. xml
1. General package

 

 
 
  
  
  
  
  
   
/Primer/success. jsp
  
  
  
   
/Primer/formSuccess. jsp
  
 


 

2. How to Set forwarding and redirection for a package

 

 
  
  
  
  
  
  
  
   
   HelloWorldAction
   /Primer
  
 

3. Use wildcards in struts. xml configuration

 

 
 
  
  
  
   
   
    
     
/Pattern/successGlobal. jsp
    
   
   
   
    
/Pattern/BookAction. jsp
   
   
   
   
   
   
   
           
   
   
   
   
   
   
    
/Pattern/BookAction. jsp
   
   
    
/Pattern/success. jsp
   
  
 

4. File Upload Configuration

 

 
 
  
  
   
   
   
    
    1229339
    
    Application/pdf, application/vnd. ms-excel, application/vnd. ms-powerpoint
    
    .Htm, .ppt
   
   
    
/Upload/success. jsp
   
   
   
    
/Upload/error. jsp
   
   
    
/Upload/success. jsp
   
   
    
/Upload/error. jsp
   
  
 

5. Custom interceptor Configuration
 
 
  
   
   
    
    
     
     
     
    
   
   
   
   
    
/Aop/success. jsp
   
   
   
    
/Aop/error. jsp
   
  
 

 

6. Form Verification configuration (1) xml configuration for manual verification (you only need to specify the input to jump to the page)

 

 
 
  
   
    
/Validate/success. jsp
   
   
   
    
/Validate/login. jsp
   
   
    
/Validate/success. jsp
   
   
   
    
/Validate/loginxml. jsp
   
  
 

(2) xml validation (for all methods in ValidateAction) (note the xml file naming rules: ValidateXmlAction-validation.xml)

 

 

 
 
 
  
  
   
   
   
    
    True
    
    
     
The user name cannot be blank.
    
   
  
  
   
   
    True
    
     
    
   
   
   
    ^ [A-Za-z0-9] {6, 12} $
    
     
    
   
  
 


 

(3) xml validation (for the specified method in ValidateAction) (note the xml file naming rules: ValidateXmlAction-validateXmlAction_login-validation.xml)

 

 
 
 
  
  
   
   
   
    
    True
    
    
     
The user name cannot be blank.
    
   
  
  
   
   
    True
    
     
    
   
   
   
    ^ [A-Za-z0-9] {6, 12} $
    
     
    
   
  
  
  
   
    
     
    
   
  
 


 

(4) custom validation (create validators. xml in the src directory and configure it as follows)

 

 
 
  
  
 


7. International Configuration

 

     
 

 

 

8. Configure token to prevent repeated submission of forms
 
 
  
   
    
     
     
     
      
      Save
     
    
   
   
   
    
/Model/add. jsp
   
   
    
/Model/success. jsp
   
   
    
/Model/edit. jsp
   
   
   
    
/Model/message. jsp
   
  
 



 

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.