[
https://issues.apache.org/jira/browse/WW-5021?focusedWorklogId=531568&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-531568
]
ASF GitHub Bot logged work on WW-5021:
--------------------------------------
Author: ASF GitHub Bot
Created on: 05/Jan/21 23:10
Start Date: 05/Jan/21 23:10
Worklog Time Spent: 10m
Work Description: JCgH4164838Gh792C124B5 commented on a change in pull
request #462:
URL: https://github.com/apache/struts/pull/462#discussion_r552245545
##########
File path: core/src/main/java/org/apache/struts2/components/UIBean.java
##########
@@ -523,6 +525,11 @@ public void setUIThemeExpansionToken(String
uiThemeExpansionToken) {
this.uiThemeExpansionToken = uiThemeExpansionToken;
}
+ @Inject(StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH)
+ public void setUiStaticContentPath(String uiStaticContentPath) {
+ this.uiStaticContentPath = uiStaticContentPath;
Review comment:
It looks like the _staticContentPath_ logic depends on the String not
ending with/terminating with "/", nor being null or empty. Maybe the setter
should refuse to accept certain "unacceptable" values, or at least produce log
warnings if they are encountered ?
For example:
```
if (uiStaticContentPath == null || uiStaticContentPath.isEmpty() ||
uiStaticContentPath.endsWith("/") {
throw new IllegalArgumentException("Static content path cannot be null,
empty or end with '/'. Provided value:" + uiStaticContentPath);
// or
LOG.warn("Static content path cannot be null, empty or end with '/'.
Provided value:{0}", uiStaticContentPath);
}
```
Refusal via exception might be safer/cleaner, if it makes sense, since it
cannot be ignored. That behaviour could be unit tested as well.
If exceptions are too disruptive, then maybe log a warning and fall-back
(override) to the "/static" default path if an unacceptable value is provided
to the setter ?
##########
File path:
core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java
##########
@@ -1344,4 +1346,12 @@ public Integer getOgnlAutoGrowthCollectionLimit() {
public void setOgnlAutoGrowthCollectionLimit(Integer
ognlAutoGrowthCollectionLimit) {
this.ognlAutoGrowthCollectionLimit = ognlAutoGrowthCollectionLimit;
}
+
+ public String getStaticContentPath() {
+ return staticContentPath;
+ }
+
+ public void setStaticContentPath(String staticContentPath) {
+ this.staticContentPath = staticContentPath;
Review comment:
If a guard or log makes sense for `UIBean`, it is the same consideration
here.
##########
File path:
core/src/main/java/org/apache/struts2/dispatcher/DefaultStaticContentLoader.java
##########
@@ -100,20 +110,23 @@
/**
* Modify state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting.
*
- * @param serveStaticContent
- * New setting
+ * @param serveStaticContent New setting
*/
@Inject(StrutsConstants.STRUTS_SERVE_STATIC_CONTENT)
public void setServeStaticContent(String serveStaticContent) {
this.serveStatic = BooleanUtils.toBoolean(serveStaticContent);
}
+ @Inject(StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH)
+ public void setStaticContentPath(String staticContentPath) {
+ this.staticContentPath = staticContentPath;
Review comment:
If a guard or log makes sense for `UIBean` and `ConstantConfig`, it is
the same consideration here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 531568)
Time Spent: 0.5h (was: 20m)
> Serve static resources from different path
> ------------------------------------------
>
> Key: WW-5021
> URL: https://issues.apache.org/jira/browse/WW-5021
> Project: Struts 2
> Issue Type: Task
> Affects Versions: 2.5.20
> Reporter: k918912
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 2.6
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> Is it somehow possible to serve the static Struts files from a different path?
> Currently domTT.js is loaded via /struts, but in my environment I would like
> to serve it via /test/struts for example. Is there any configuration I'm
> missing or is this currently not possible?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)