Date: Tue, 19 Mar 2024 08:22:53 +0000 (UTC) Message-ID: <1862118543.55996.1710836573976@cwiki-he-fi.apache.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_55995_566801851.1710836573976" ------=_Part_55995_566801851.1710836573976 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Deprecated Plugin
Since 2.1 this plugin has been deprecated in favor of the Convention Plugin. See this page for details on how to port your application to t= he Convention plugin.
The Codebehind Plugin reduces mundane configuration by adding "Page Cont= roller" conventions.
There are two common situations where the plugin applies convention over= configuration:
To improve the first case, the plugin will detect the presence of a page= with no corresponding Struts mapping and automatically substitute a mappin= g that uses the default Action class for the package, which is usually Acti= onSupport, a NO-OP Action.
For the problem of default results, the plugin will make it unnecessary = to define those results by detecting the presence of a page for that Action= and creating the appropriate configuration on-the-fly.
In these two ways, the plugin encourages a page-based development style,= handling the linking of Struts actions with pages and pages with Results i= n a common way.
To see the plugin in act= ion, review the "Person Manager" example in the Showcase application.
To use this plugin, simply copy its jar into your application. The plugi= n can be used to find default mappings and results.
To better facilitate a code-behind development approach, the plugin will= detect the case where the request has no defined Struts action mapping, ye= t there exists a corresponding page. It will then create a dummy action map= ping referencing the default Action class (usually ActionSupport), allowing= the page to be displayed normally. Additionally, the default interceptor s= tack for the configured package will be applied, bringing the workflow bene= fits of interceptor stacks to simple pages.
When no explicitly configured Action can be found for a request, the plu= gin searches the web application for a likely page. Specifically, the follo= wing pattern is used to locate a page:
/NAMESPACE/ACTION.(jsp|vm|ftl)
For example, if the request is for http=
://www.company.com/myapp/member/login.action
, the plugin will lo=
ok for the following pages, in this order:
/member/login.jsp
/member/login.vm
/member/login.ftl
If any of those pages are found, the plugin will construct an ActionConf=
ig object on the fly, using the ActionSupport class for the Action and a si=
ngle Result that points to the discovered page. The ActionConfig will be pu=
t in the configured package, meaning that it will inherit the default Inter=
ceptor stack for that package. The default package is codebehind-defa=
ult
, however, it can be configured in any configuration file via the struts=
.codebehind.defaultPackage
constant.
In many applications, a majority of Results could have the same root nam=
e as the action mapping. To reduce this unnecessary configuration, the Stru=
ts plugin will try to guess the appropriate Result, if none is explicitly c=
onfigured. This technique works for any result code, including succes=
s
. When combined with the Zero Configuration style, the amount of configuration in an=
application dwindles to next to nothing.
When no explicitly configured Result is found for an Action's result cod= e, the plugin, again, searches the web application for a matching page. Spe= cifically, the following patterns, in the following order, are used to loca= te a page:
/NAMESPACE/ACTION-RESULT_CODE.(jsp|vm|ftl)
/NAMESPACE/ACTION.(jsp|vm|ftl)
These two patterns are searched for each of the three default page exten=
sions: jsp, vm, and ftl. For example, if the request is for http://www.company.com/myapp/member/login.action, so that the action name is
, and the Action class returned a code of login
and the namespace is success, the plugin will look for the following pages, in this order:
/member/login-success.jsp
/member/login.jsp
/member/login-success.vm
/member/login.vm
/member/login-success.ftl
/member/login.ftl
If any of those pages are found, the appropriate Result will be construc= ted and processed.
The following settings can be customized. See the developer guide.
Setting |
Description |
Default |
Possible Values |
---|---|---|---|
|
The default package to use for created Action= mappings |
|
Any existing package name |
|
Whether to disable scanning the classpath for= Action classes or not |
|
|
This plugin can be installed by copying the plugin jar into your applica=
tion's /WEB-INF/lib
directory. No other files need to be copie=
d or created.