facebook

multipartResolver

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #341480 Reply

    ismoore999
    Member

    Hi
    I have been trying to use a file uploader in myeclipse scaffolded project from AJAX.

    In the controller, and from examples I could find on the web, I used the following

        /**
         * @ModelReference [platform:/resource/iActsCommon/.springDSL/com/tscape/iacts/web/rest/NotificationRestController/addAttachment%7B600db692-7097-4bf4-8f0a-d2f4c01578ca%7D/.properties.swoperation]
         */
        @RequestMapping(value = "/script/notification/addAttachment.action", method = RequestMethod.POST)
        @ResponseBody
        public Map addAttachment(@RequestParam Integer notificationId, @ModelAttribute FileUploadForm file) {
            org.springframework.web.multipart.MultipartFile multipartFile = file.getFile();
    

    but this always shows an error

    
    java.lang.NoSuchMethodError: org.springframework.web.multipart.commons.CommonsFileUploadSupport$MultipartParsingResult.getMultipartFiles()Ljava/util/Map;
    

    when using the standard skyway multipart uploader

    org.skyway.spring.util.web.binary.ModelBindingMultipartResolver

    I therefore changed the multipartResolver bean in the *.web-context.xml to

    
        <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
    

    which fixes the issue but as this is a file that is generated by MyEclipse it is often overwritten back to the orignal value and then I have to re-edit it.

    How can I do an upload using the skyway product?

    #341501 Reply

    support-tony
    Keymaster

    ismoore999,

    You can alter the templates used to generate code and files, rather than alter the generated files themselves.

    Please take a look at the Customize Code Generation Tutorial. It should be quite easy in your two cases.

    The template for the two files you want to alter can be found under the com.skyway.integration.java.spring/templates folder, spring-context/web-context.jet and web/web-xml.jet.

    For the web-context file, just search for the multipartResolver definition and change the class. For the web.xml file, search for the iteration through filters and filter-mappings. For each iteration processing, wrap it in

    <c:setVariable select="$filterDefinition/@name" var="filterName"/>
    <c:if test="$filterName != 'Sitemesh Filter'">
    ....
    </c:if>

    If this doesn’t work, could you please let us know which version of Spring is specified for your project (e.g. 3.0 or 3.1) and also include the output from MyEclipse->Installation Summary->Installation Details (note that this is different from the information in Help->About->Installation Details).

    #342127 Reply

    ismoore999
    Member

    Thanks for that. I have tried this and I can get it to work.

    However, I have on other question…

    I have also added scaffolding for security and I need to modify some of the parameters that I previously added (for example, I put the wrong URL for he second intercept below and I incorrectly set the authentification for the logon page.

        <http auto-config="true" >
            <intercept-url pattern='/pages/login.jsp' access="IS_AUTHENTICATED_ANONYMOUSLY" />
            <intercept-url pattern="/script/*" access="IS_AUTHENTICATED_REMEMBERED" />
            <form-login login-page="/pages/login.jsp" authentication-failure-url="/pages/login.jsp?login_error=true"  /> 
            <logout logout-success-url="/pages/logout-redirect.jsp" invalidate-session="true" />
            <remember-me key="iActsCommonRMKey" user-service-ref="userDetailsService" />
        </http>
    

    However cannot see how I can change the parameters that I entered during scaffolding and if I look in the scaffolding in security-context.jet I see

        <http auto-config="true" <c:if test="$springJeeProject/securitySettings/accessDeniedView/@text" >access-denied-page="<c:get select="$springJeeProject/securitySettings/accessDeniedView/@text" />"</c:if>>
            <c:if test="$springJeeProject/securitySettings/loginView/@text">
            <intercept-url pattern='<c:get select="$springJeeProject/securitySettings/loginView/@text" />' <c:if test="toBoolean($springSecurity2)">filters='none'</c:if>/>
            </c:if>
            <c:iterate select="$springJeeProject/securitySettings/securedUrlPatterns" var="urlPattern">
            <intercept-url pattern="<c:get select="$urlPattern/@urlPattern" />" <c:choose><c:when test="$urlPattern/@secured = 'true'">access="<c:get select="$urlPattern/@access" />" /></c:when><c:otherwise>filters='none' /></c:otherwise></c:choose>
            </c:iterate>
            <form-login <c:if test="$springJeeProject/securitySettings/loginView/@text">login-page="<c:get select="$springJeeProject/securitySettings/loginView/@text" />" </c:if><c:if test="$springJeeProject/securitySettings/loginFailureView/@text">authentication-failure-url="<c:get select="$springJeeProject/securitySettings/loginFailureView/@text" />" </c:if><c:if test="$springJeeProject/securitySettings/loginSuccessView/@text">always-use-default-target="<c:get select="$springJeeProject/securitySettings/@alwaysUseDefaultTarget" />" default-target-url="<c:get select="$springJeeProject/securitySettings/loginSuccessView/@text" />"</c:if> /> 
            <c:if test="$springJeeProject/securitySettings/logoutSuccessView/@text">
            <logout logout-success-url="<c:get select="$springJeeProject/securitySettings/logoutSuccessView/@text" />" invalidate-session="true" />
            </c:if>
    

    where are the values that this is using and how can I modify them? I

    Thanks in advance

    #342151 Reply

    support-tony
    Keymaster

    ismoore999,

    The values you want to change are entered during scaffolding and so will not be in the template. Have you tried re-scaffolding security, using the correct values? This should regenerate the security context to what you want.

    Please let us know if this helps.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: multipartResolver

You must be logged in to post in the forum log in