Hi all,

 

I met a problem that I don't know how to solve it. 

 

When I send a URL like  http://localhost/hello/a!b which contains "!", the
server will return 500. 

 

The struts and web configuration is as below:

Struts.xml

    <package name="test" extends="struts-default" namespace="/hello">

        <action name="*" class="com.example.action.Test" method="hi">

            <param name="name">{1}</param>

            <result name="success">/WEB-INF/ftl/hello.ftl</result>

        </action>

</package>

 

Web.xml

    <filter>

        <filter-name>struts2</filter-name>

 
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecut
eFilter</filter-class>

    </filter>

     <filter-mapping>

        <filter-name>struts2</filter-name>

        <url-pattern>/*</url-pattern>

    </filter-mapping>

 

Action Code:

 

    private String name;

 

    public String getName() {

        return name;

    }

 

    public void setName(String name) {

        this.name = name;

    }

 

    public String hi(){

        return SUCCESS;

    }

 

 

And I tried another way, nod passed the value in the url.  And I tried the
invalid url : http://localhost/hello/gir!haha    and I can got the expected
result 404," not found the action" as the struts will analysis the url and 

set "haha" as the invoke method.

 

    <package name="test" extends="struts-default" namespace="/hello">

        <action name="girl" class="com.example.action.Test" method="hi">

            <result name="success">/WEB-INF/ftl/hello.ftl</result>

        </action>

</package>

 

Action code:

    public String hi(){

        ActionContext.getContext().getValueStack().set("name","ann");

        return SUCCESS;

    }

 

Thanks

Dyun.

Reply via email to