Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

if the url with &amp is used in the value attribute it will not work properly unless the escapeXml is set to false.

Why aren't my get parameters being propagated automatically under Websphere 5.1?

The symptoms of this issue is that the when using the s:url tag, the get parameters won't be inlcuded when the includedParams attribute is set to 'get' under Websphere 5.1. (Websphere 6.1 is not affected by this issue) This issue occurs because Websphere 5.1 doesn't follow correct behavior regarding the request query string. To allow struts to work properly with Websphere 5.1, you must include the following interceptor in your interceptor stack:

Code Block

package example;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 * Since websphere 5.1 doesn't retain the query string past a forward, this
 * interceptor populates the 2.4 query string servlet attribute.
 */
public class Websphere51QueryStringInterceptor implements Interceptor
{
  /** Servlet 2.4 location of the query string after a forward. */
  public static final String FORWARD_QUERY_STRING_ATTRIBUTE = "javax.servlet.forward.query_string";

  /**
   * @see com.opensymphony.xwork.interceptor.Interceptor#init()
   */
  public void init()
  {
  }

  /**
   * @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
   */
  public String intercept(ActionInvocation invocation) throws Exception
  {
    HttpServletRequest request = (HttpServletRequest) invocation
      .getInvocationContext().get(StrutsStatics.HTTP_REQUEST);
    String queryString = request.getQueryString();
    if (queryString != null)
    {
      if (request.getAttribute(FORWARD_QUERY_STRING_ATTRIBUTE) == null)
      {
        request.setAttribute(FORWARD_QUERY_STRING_ATTRIBUTE, queryString);
      }
    }
    return invocation.invoke();
  }

  /**
   * @see com.opensymphony.xwork.interceptor.Interceptor#destroy()
   */
  public void destroy()
  {
  }
}

This interceptor will grab the query string from the request before the forward occurs and put it under the query string servlet attribute as defined in the 2.4 servlet spec. This interceptor should have no affect on other servlet containers.

See https://issues.apache.org/struts/browse/WW-1563Image Added for more details.

Validation

How to disable validation on the first page load (to show a in input form)?

...