diff --git a/core/src/main/java/org/apache/struts2/result/PlainTextResult.java b/core/src/main/java/org/apache/struts2/result/PlainTextResult.java
index c264817de..7baaa055c 100644
--- a/core/src/main/java/org/apache/struts2/result/PlainTextResult.java
+++ b/core/src/main/java/org/apache/struts2/result/PlainTextResult.java
@@ -31,15 +31,8 @@ import java.io.PrintWriter;
import java.nio.charset.Charset;
/**
- *
- *
* A result that send the content out as plain text. Useful typically when needed
* to display the raw content of a JSP or Html file for example.
- *
- *
- *
- *
- *
*
*
* - location (default) = location of the file (jsp/html) to be displayed as plain text.
@@ -47,26 +40,18 @@ import java.nio.charset.Charset;
* response type (eg. Content-Type=text/plain; charset=UTF-8) and when reading
* using a Reader. Some example of charSet would be UTF-8, ISO-8859-1 etc.
*
- *
- *
- *
- *
- *
- *
*
+ *
* <action name="displayJspRawContent" >
* <result type="plainText">/myJspFile.jsp</result>
* </action>
*
- *
* <action name="displayJspRawContent" >
* <result type="plainText">
* <param name="location">/myJspFile.jsp</param>
* <param name="charSet">UTF-8</param>
* </result>
* </action>
- *
- *
*
*/
public class PlainTextResult extends StrutsResultSupport {
diff --git a/core/src/main/java/org/apache/struts2/result/ServletRedirectResult.java b/core/src/main/java/org/apache/struts2/result/ServletRedirectResult.java
index 0973492d7..9d7b461e6 100644
--- a/core/src/main/java/org/apache/struts2/result/ServletRedirectResult.java
+++ b/core/src/main/java/org/apache/struts2/result/ServletRedirectResult.java
@@ -46,8 +46,6 @@ import java.util.Map;
import static javax.servlet.http.HttpServletResponse.SC_FOUND;
/**
- *
- *
* Calls the {@link HttpServletResponse#sendRedirect(String) sendRedirect}
* method to the location specified. The response is told to redirect the
* browser to the specified location (a new request from the client). The
@@ -56,33 +54,19 @@ import static javax.servlet.http.HttpServletResponse.SC_FOUND;
* available. This is because actions are built on a single-thread model. The
* only way to pass data is through the session or with web parameters
* (url?name=value) which can be OGNL expressions.
- *
- *
- *
+ *
* This result type takes the following parameters:
- *
- *
*
*
- *
* - location (default) - the location to go to after execution.
- *
* - parse - true by default. If set to false, the location param will
* not be parsed for Ognl expressions.
- *
* - anchor - Optional. Also known as "fragment" or colloquially as
* "hash". You can specify an anchor for a result.
*
- *
- *
* This result follows the same rules from {@link StrutsResultSupport}.
- *
- *
- *
- *
- * Example:
- *
*
+ * Example:
*
*
* <!--
diff --git a/core/src/main/java/org/apache/struts2/result/StreamResult.java b/core/src/main/java/org/apache/struts2/result/StreamResult.java
index 47dbc4593..711929f4a 100644
--- a/core/src/main/java/org/apache/struts2/result/StreamResult.java
+++ b/core/src/main/java/org/apache/struts2/result/StreamResult.java
@@ -27,60 +27,46 @@ import java.io.InputStream;
import java.io.OutputStream;
/**
- *
- *
* A custom Result type for sending raw data (via an InputStream) directly to the
* HttpServletResponse. Very useful for allowing users to download content.
- *
- *
- *
+ *
* This result type takes the following parameters:
- *
- *
*
*
- *
* - contentType - the stream mime-type as sent to the web browser
* (default =
text/plain).
- *
* - contentLength - the stream length in bytes (the browser displays a
* progress bar).
- *
* - contentDisposition - the content disposition header value for
* specifing the file name (default =
inline, values are typically
* attachment;filename="document.pdf".
- *
* - inputName - the name of the InputStream property from the chained
* action (default =
inputStream).
- *
* - bufferSize - the size of the buffer to copy from input to output
* (default =
1024).
- *
* - allowCaching if set to 'false' it will set the headers 'Pragma' and 'Cache-Control'
* to 'no-cahce', and prevent client from caching the content. (default =
true)
- *
* - contentCharSet if set to a string, ';charset=value' will be added to the
* content-type header, where value is the string set. If set to an expression, the result
* of evaluating the expression will be used. If not set, then no charset will be set on
* the header
*
*
- * These parameters can also be set by exposing a similarly named getter method on your Action. For example, you can
- * provide getContentType() to override that parameter for the current action.
*
- *
- *
- * Example:
+ * These parameters can also be set by exposing a similarly named getter method on your Action. For example, you can
+ * provide getContentType() to override that parameter for the current action.
*
*
- *
+ * Example:
+ *
+ *
* <result name="success" type="stream">
* <param name="contentType">image/jpeg</param>
* <param name="inputName">imageStream</param>
* <param name="contentDisposition">attachment;filename="document.pdf"</param>
* <param name="bufferSize">1024</param>
* </result>
- *
+ *
*/
public class StreamResult extends StrutsResultSupport {
diff --git a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
index d213f5a79..7cc1aab24 100644
--- a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
+++ b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
@@ -18,26 +18,20 @@
*/
package org.apache.struts2.views.util;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.util.StrutsUtil;
import org.apache.struts2.views.jsp.ui.OgnlTool;
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
-import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.util.ValueStack;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.Map;
/**
* Value Stack's Context related Utilities.
- *
*/
public class ContextUtil {
public static final String REQUEST = "request";
@@ -48,7 +42,7 @@ public class ContextUtil {
public static final String OGNL = "ognl";
public static final String STRUTS = "struts";
public static final String ACTION = "action";
-
+
public static Map getStandardContext(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
HashMap map = new HashMap<>();
map.put(REQUEST, req);
@@ -68,6 +62,7 @@ public class ContextUtil {
/**
* Return true if either Configuration's altSyntax is on or the stack context's useAltSyntax is on
+ *
* @param context stack's context
* @return boolean
*/
@@ -76,18 +71,22 @@ public class ContextUtil {
// plus the Configuration implementation should cache the properties, which the framework's
// configuration implementation does
String tagAltSytnax = ActionContext.of(context).getContainer().getInstance(String.class, StrutsConstants.STRUTS_TAG_ALTSYNTAX);
- return "true".equals(tagAltSytnax) ||(
- (context.containsKey("useAltSyntax") &&
- context.get("useAltSyntax") != null &&
- "true".equals(context.get("useAltSyntax").toString())));
+
+ return "true".equals(tagAltSytnax) || (
+ (context.containsKey("useAltSyntax") &&
+ context.get("useAltSyntax") != null &&
+ "true".equals(context.get("useAltSyntax").toString()))
+ );
}
/**
* Returns a String for overriding the default templateSuffix if templateSuffix is on the stack
+ *
* @param context stack's context
* @return String
*/
public static String getTemplateSuffix(Map context) {
return context.containsKey("templateSuffix") ? (String) context.get("templateSuffix") : null;
}
+
}
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
index 74765bf5a..895639019 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
@@ -39,7 +39,6 @@ import javax.servlet.jsp.PageContext;
import java.util.HashMap;
import java.util.Map;
-
/**
* Unit test for {@link ActionTag}.
*/
@@ -156,7 +155,7 @@ public class ActionTagTest extends AbstractTagTest {
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
- assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
+ assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
assertTrue(result.isExecuted());
}
@@ -177,11 +176,11 @@ public class ActionTagTest extends AbstractTagTest {
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
- assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
+ assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
assertNull(result); // result is never executed, hence never set into invocation
}
- public void testExecuteButResetReturnSameInvocation() throws Exception {
+ public void testExecuteButResetReturnSameInvocation() throws Exception {
Mock mockActionInv = new Mock(ActionInvocation.class);
ActionTag tag = new ActionTag();
tag.setPageContext(pageContext);
@@ -199,7 +198,7 @@ public class ActionTagTest extends AbstractTagTest {
ActionComponent component = (ActionComponent) tag.getComponent();
tag.doEndTag();
- assertSame(oldInvocation, ActionContext.getContext().getActionInvocation());
+ assertSame(oldInvocation, ActionContext.getContext().getActionInvocation());
}
public void testIngoreContextParamsFalse() throws Exception {
@@ -236,7 +235,7 @@ public class ActionTagTest extends AbstractTagTest {
tag.setIgnoreContextParams(true);
Map params = new HashMap<>();
- params.put("user", new String[] { "Santa Claus" });
+ params.put("user", new String[]{"Santa Claus"});
ActionContext.getContext().setParameters(HttpParameters.create(params).build());
tag.doStartTag();
@@ -264,7 +263,7 @@ public class ActionTagTest extends AbstractTagTest {
tag.doEndTag();
fail("Should have thrown RuntimeException");
} catch (StrutsException e) {
- assertEquals("tag 'actioncomponent', field 'name': Action name is required. Example: updatePerson", e.getMessage());
+ assertEquals("tag 'actioncomponent', field 'name': Action name is required. Example: updatePerson", e.getMessage());
}
}
@@ -287,7 +286,7 @@ public class ActionTagTest extends AbstractTagTest {
tag.setNamespace("");
tag.setName("testActionTagAction!input");
tag.setExecuteResult(true);
- ((DefaultActionMapper)container.getInstance(ActionMapper.class)).setAllowDynamicMethodCalls("true");
+ ((DefaultActionMapper) container.getInstance(ActionMapper.class)).setAllowDynamicMethodCalls("true");
tag.doStartTag();
@@ -299,13 +298,15 @@ public class ActionTagTest extends AbstractTagTest {
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
- assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
+ assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
assertTrue(result.isExecuted());
}
protected void setUp() throws Exception {
super.setUp();
- initDispatcher(new HashMap() {{ put("configProviders", TestConfigurationProvider.class.getName()); }});
+ initDispatcher(new HashMap() {{
+ put("configProviders", TestConfigurationProvider.class.getName());
+ }});
createMocks();
}
diff --git a/plugins/rest/src/main/java/org/apache/struts2/rest/RestWorkflowInterceptor.java b/plugins/rest/src/main/java/org/apache/struts2/rest/RestWorkflowInterceptor.java
index 63654ee57..6a981c8e5 100644
--- a/plugins/rest/src/main/java/org/apache/struts2/rest/RestWorkflowInterceptor.java
+++ b/plugins/rest/src/main/java/org/apache/struts2/rest/RestWorkflowInterceptor.java
@@ -34,17 +34,17 @@ import java.util.Map;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
/**
- *
- *
* An interceptor that makes sure there are not validation errors before allowing the interceptor chain to continue.
* This interceptor does not perform any validation.
+ *
+ *
+ * Copied from the {@link com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor}, this interceptor adds support
+ * for error handling of Restful operations. For example, if an validation error is discovered, a map of errors
+ * is created and processed to be returned, using the appropriate content handler for rendering the body.
*
*
- * Copied from the {@link com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor}, this interceptor adds support for error handling of Restful
- * operations. For example, if an validation error is discovered, a map of errors is created and processed to be
- * returned, using the appropriate content handler for rendering the body.
- *
- * This interceptor does nothing if the name of the method being invoked is specified in the excludeMethods
+ *
+ * This interceptor does nothing if the name of the method being invoked is specified in the excludeMethods
* parameter. excludeMethods accepts a comma-delimited list of method names. For example, requests to
* foo!input.action and foo!back.action will be skipped by this interceptor if you set the
* excludeMethods parameter to "input, back".
@@ -58,34 +58,20 @@ import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
* all methods for both parameters.
* See {@link MethodFilterInterceptor} for more info.
*
- *
*
- * Interceptor parameters:
- *
- *
+ * Interceptor parameters:
*
*
- *
* - inputResultName - Default to "input". Determine the result name to be returned when
* an action / field error is found.
- *
*
- *
- *
*
- *
Extending the interceptor:
- *
- *
- *
+ * Extending the interceptor:
* There are no known extension points for this interceptor.
- *
- *
*
- * Example code:
+ * Example code:
*
*
- *
- *
* <action name="someAction" class="com.examples.SomeAction">
* <interceptor-ref name="params"/>
* <interceptor-ref name="validation"/>
@@ -118,8 +104,6 @@ import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
* </interceptor-ref>
* <result name="success">good_result.ftl</result>
* </action>
- *
- *
*
*
* @author Jason Carreira