struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philipp Heidelbach (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4930) SMI cannot be diasabled for action-packages found via the convention-plugin
Date Thu, 05 Apr 2018 14:37:00 GMT

    [ https://issues.apache.org/jira/browse/WW-4930?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16427031#comment-16427031
] 

Philipp Heidelbach commented on WW-4930:
----------------------------------------

h3.  *Example Action:*
{code:java}
public class JsonImportAction extends BaseAction {

    private static final long serialVersionUID = 1L;

    private static final String ACTION_NAMESPACE = "stammdaten/";

    private static final String FORM = "json-import-form";

    private static final String UPLOAD_ID = "upload";

    @Getter
    @Setter
    private File upload;

    @Getter
    @Setter
    private String uploadFileName;

    @Inject
    private JsonImportService jsonImport;

    public void validateImportJson() {
        setResult(ACTION_NAMESPACE + FORM);
        commonValidate(UPLOAD_ID);
    }

    public String importJson() {
        try {
            jsonImport.jsonImport(upload);
        } catch (final SQLException e) {
            e.printStackTrace();
        }
        addActionMessage(getText("jsonImport.success"));
        return INPUT;
    }

    private void commonValidate(final String uploadId) {
        if (upload == null) {
            addFieldError(uploadId, getText("jsonImport.chooseFile"));
        } else if (!StringUtils.equalsIgnoreCase("json", FilenameUtils.getExtension(uploadFileName)))
{
            addFieldError(uploadId, getText("jsonImport.chooseFile.error"));
        } else if (upload.length() == 0) {
            addFieldError(uploadId, getText("jsonImport.empty"));
        }
    }
}

{code}
*Beginning of our BaseAction:*
{code:java}
@ParentPackage("default")
@Result(name = Action.INPUT, location = "/WEB-INF/jsp/${result}.jsp")
public class BaseAction extends ActionSupport
        implements ServletContextAware, ServletRequestAware, ServletResponseAware {
{code}
*And the corresponding view component:*
{code:java}
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="../../includes/taglib.jsp" %>
<s:form
    action="json-import!importJson.action?ajax=true"
    enctype="multipart/form-data"
    id="jsonImportForm"
    namespace="/stammdaten"
    method="post"
    theme="simple"
>
    <s:label cssClass="small" key="jsonImport.chooseFile" for="upload" />
    <s:file cssClass="c8" id="upload" name="upload" accept="application/json" />
    <div class="clear"></div>
    <hr />
    <div class="c4md right">
        <sj:submit cssClass="c2 right" key="button.import" targets="jsonImportFormDiv"
/>
    </div>
</s:form>
<jsp:include page="../../includes/error-fields.jsp" />
{code}

> SMI cannot be diasabled for action-packages found via the convention-plugin
> ---------------------------------------------------------------------------
>
>                 Key: WW-4930
>                 URL: https://issues.apache.org/jira/browse/WW-4930
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Convention
>    Affects Versions: 2.5.16
>         Environment: Windows 10
> Java 1.8
>            Reporter: Philipp Heidelbach
>            Priority: Major
>             Fix For: 2.6
>
>
> I'm trying to update Struts 2.3.34 to 2.5.16 and disabling SMI doesn't seem to work.
> I debuged XmlConfigurationProvider but in the packageConfig of our package (named default
see below) SMI is correctly set to false. Debugging PackageBaseActionConfigBuilder shows that
our default-package is used as parent package and in the parentPkg SMI is set to false. The
pkgConfig however is alwasy null (line: 1043) and so a new package config is created in which
SMI is set to true.
> Thus for all these actions methods i get the error that these methods aren't allowed.
> If I use @AllowedMethod-annotations it works fine.
> Below the beginning of our struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE struts PUBLIC
>     "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
>     "http://struts.apache.org/dtds/struts-2.5.dtd">
> <struts>
>     <constant name="struts.action.extension" value="action" />
>     <constant name="struts.convention.action.fileProtocols" value="jar,zip,vfsfile,vfszip"
/>
>     <constant name="struts.convention.action.includeJars" value=".*/newd[-.\w]*\.jar(!/)?"
/>
>     <constant name="struts.convention.exclude.packages" value="org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.*"
/>
>     <constant name="struts.convention.result.path" value="/WEB-INF/jsp/" />
>     <constant name="struts.custom.i18n.resources" value="applicationResources" />
>     <constant name="struts.locale" value="de_DE" />
>     <constant name="struts.multipart.maxSize" value="52428800" />
>     <constant name="struts.objectFactory" value="spring" />
>     <constant name="struts.enable.DynamicMethodInvocation" value="true" />
>     <constant name="struts.ui.theme" value="simple" />
>     <constant name="struts.ui.templateDir" value="template" />
>     <constant name="struts.devMode" value="false" />
>     <constant name="struts.el.throwExceptionOnFailure" value="true" />
>     <package name="default" extends="struts-default" strict-method-invocation="false">
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message