Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3832

Convention cannot work when "struts.convention.result.flatLayout" set to FALSE

    XMLWordPrintableJSON

Details

    • Patch

    Description

      The convention cannot work, when i set struts.convention.result.flatLayout" to FALSE

      steps:

      1. create a struts2 webapp, with struts2-convention-plugin-2.3.4 and struts2-rest-plugin-2.3.4.

      2. in struts.xml, i wrote:

      <struts>
          <constant name="struts.convention.action.suffix" value="Controller"/>
          <constant name="struts.convention.action.mapAllMatches" value="true"/>
          <constant name="struts.convention.default.parent.package" value="rest-default"/>
      
          <constant name="struts.convention.package.locators" value="example"/>
          <constant name="struts.i18n.reload" value="true"/>
      	<constant name="struts.devMode" value="true"/>
      	<constant name="struts.convention.result.flatLayout" value="false"/> 
      	<constant name="struts.convention.classes.reload" value="true" />    
      	<constant name="struts.convention.action.includeJars" value="false" />
          <constant name="struts.convention.exclude.packages" value="org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.*"/>
      </struts>
      

      3. I entered https://localhost:8080/CONTEXT/users/1, and expected the server return the JSP file located in "..\webapp\WEB-INF\content\users\show.jsp", BUT it cannot found the file.

      4. I tried to review the SOURCE, and found that there MIGHTBE something wrong in L363 in DefaultResultMapBuilder.java file.

      <pre>
      /*
       * $Id: DefaultResultMapBuilder.java 1099705 2011-05-05 07:17:33Z jogep $
       */
      
      //...
      
        public class DefaultResultMapBuilder implements ResultMapBuilder {
      
      //...
      
          protected void makeResults(Class<?> actionClass, String path, String resultPrefix,
                  Map<String, ResultConfig> results, PackageConfig packageConfig,
                  Map<String, ResultTypeConfig> resultsByExtension) {
              if (path.startsWith(resultPrefix)) {
                  int indexOfDot = path.indexOf('.', resultPrefix.length());
      
                  // This case is when the path doesn't contain a result code
                  
      /*L363*/    if (indexOfDot == resultPrefix.length() || !flatResultLayout) {
                      if (LOG.isTraceEnabled()) {
                          LOG.trace("The result file [#0] has no result code and therefore" +
                              " will be associated with success, input and error by default. This might" +
                              " be overridden by another result file or an annotation.", path);
                      }
      
      </pre>
      

      5. I wonder that the "||" should be "&&"?

      Attachments

        Issue Links

          Activity

            People

              lukaszlenart Lukasz Lenart
              f393907 jun fang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: