Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/core-developers/package-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ Since Struts 7.5.0 these core constants are scopable:
- `struts.ui.templateDir`, the default template directory of UI tags, see
[Selecting Template Directory](../tag-developers/selecting-template-directory)

The [Convention plugin](../plugins/convention/) makes `struts.convention.result.path` scopable, see
[Result path per package](../plugins/convention/#result-path-per-package).

Plugins and your own application code can declare more, see [Making a constant scopable](#making-a-constant-scopable).

The configuration is validated at startup, and loading fails when:
Expand Down
21 changes: 21 additions & 0 deletions source/plugins/convention/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,27 @@ public class HelloWorld extends ActionSupport {

The result for this class will be located in `WEB-INF/jsps` rather than the default of `WEB-INF/content`.

#### Result path per package

Since Struts 7.5.0 a parent package can set the result path for all actions placed under it with a
[scoped constant](../../core-developers/package-configuration#scoped-constants):

```xml
<package name="admin-base" extends="convention-default">
<scoped-constant name="struts.convention.result.path" value="/WEB-INF/admin/"/>
</package>
```

Actions pick it up from the package they are placed under, chosen with `@ParentPackage("admin-base")` or
`struts.convention.default.parent.package`. The result path of an action is taken from, in order:

1. `@ResultPath` on the action class or its Java package
2. the `struts.convention.result.path` scoped constant of the action's package, including inherited ones
3. the global `struts.convention.result.path` constant

A request without an action class, served straight from a template, uses the scoped constant of the default
parent package (`struts.convention.default.parent.package`).

### ParentPackage annotation

The ParentPackage annotation allows applications to define different parent Struts package for specific action classes
Expand Down