Struts Convention Plugin Process (2.1.6+)

Source: Internet
Author: User

First add Lib:

<Dependency>          <groupId>Org.apache.struts</groupId>          <Artifactid>Struts2-config-browser-plugin</Artifactid>          <version>2.3.20</version>      </Dependency>      <Dependency>          <groupId>Org.apache.struts</groupId>          <Artifactid>Struts2-convention-plugin</Artifactid>          <version>2.3.20</version>      </Dependency>

Access Http://localhost:8080/conv/config-browser/a.action to see all the paths that are currently mapped

The plugins are executed in the following order:

1. Look for the following packages:,, struts struts2 action ,actions

任何深度找到的以上包都自动作为根目录

2.然后在包内寻找以下类:实现了com.opensymphony.xwork2.Action或者继承了com.opensymphony.xwork2.ActionSupport,或类名以Action结尾

3.映射为url:

Com.example. actions. Mainaction,/maincom.example. actions. Products. Display,/products/displaycom.example. struts. Company.details.ShowCompanyDetailsAction-/company/details/show-company-details (all lowercase)

Like what

Will map to,

You can skip some packages: struts.convention.exclude.packages =org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*, Org.springframework.web.struts2.*,org.hibernate.* (skipped packages are no longer added, even if manually added)

Auto-Search Package name: struts.convention.package.locators =action,actions,struts,struts2

Automatically search for package names beginning with: struts.convention.package.locators.basepackage=

Auto-search End of class name: Struts.convention.action.suffix=action

To specify a specific package manually: struts.convention.action.packages=

4. Default, all the result is here to find:web-inf/content

For example, you can access the http://localhost:8080/conv/my-jsp.action through the

Can be controlled by constant: struts.convention.result.path =/web-inf/content/

Depending on the return type and the return string, a different name is required:

5. If the page file cannot be found, it is considered an action, and the other action can add @action ("XX") to the method, indicating the specific path, which is the result type chain

As in,

 Public class extends Actionsupport {    public  String execute () {        return ' here ";      }}
 Public class extends actionsupport {       @Action ("my-jsp-here")//by specifying a specific path to implement chain, provided that the page file      is not public   String execute () {        return "yes";      }}

will eventually become,

You can set automatic overloading:

<constantname="struts.devMode" value="true"/>

<constantname="struts.convention.classes.reload" value="true" />

Struts.convention.action.alwaysMapExecute =false Disable automatic call to execute ()

Struts.convention.action.disablescanning=true Disabling scanning

Struts.convention.action.mapAllMatches =true No @action also auto map

Struts.convention.action.name.lowercase=false don't turn into lowercase

Struts.convention.action.name.separator=_ Name Separator

Struts.convention.action.eagerloading=true improves performance when you don't use spring

Struts Convention Plugin Process (2.1.6+)

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.