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

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

    Details

    • Flags:
      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 "&&"?

        Issue Links

          Activity

          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Struts2-JDK6 #826 (See https://builds.apache.org/job/Struts2-JDK6/826/)
          WW-3832 Solves problem when not using flat layout with Convention plugin (lukaszlenart: rev 1535364)

          • /struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java
          • /struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Struts2-JDK6 #826 (See https://builds.apache.org/job/Struts2-JDK6/826/ ) WW-3832 Solves problem when not using flat layout with Convention plugin (lukaszlenart: rev 1535364) /struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java /struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          Done, please check with the latest snapshot

          Show
          lukaszlenart Lukasz Lenart added a comment - Done, please check with the latest snapshot
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 1535364 from Lukasz Lenart in branch 'struts2/trunk'
          [ https://svn.apache.org/r1535364 ]

          WW-3832 Solves problem when not using flat layout with Convention plugin

          Show
          jira-bot ASF subversion and git services added a comment - Commit 1535364 from Lukasz Lenart in branch 'struts2/trunk' [ https://svn.apache.org/r1535364 ] WW-3832 Solves problem when not using flat layout with Convention plugin
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          The simplest way is to take the source, apply your change and test.

          Show
          lukaszlenart Lukasz Lenart added a comment - The simplest way is to take the source, apply your change and test.

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development