You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Danyun.Liu" <da...@gmail.com> on 2011/03/07 03:51:37 UTC

invalid charactors in url and 500 error

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.


Re: invalid charactors in url and 500 error

Posted by DanY Liu <da...@gmail.com>.
Thank you so much. It just solved my problem. :)

On Mon, Mar 7, 2011 at 11:17 AM, Maurizio Cucchiara <
maurizio.cucchiara@gmail.com> wrote:

> The exclamation mark has a special meaning for the struts2, have you
> tried to inhibit by disabling DMI?
>
> Try to add this row inside your struts.xml file.
> <constant name="struts.enable.DynamicMethodInvocation" value="false" />
>
>
> On 7 March 2011 03:51, Danyun.Liu <da...@gmail.com> wrote:
> > 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.
> >
> >
>
>
>
> --
> Maurizio Cucchiara
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: invalid charactors in url and 500 error

Posted by Maurizio Cucchiara <ma...@gmail.com>.
The exclamation mark has a special meaning for the struts2, have you
tried to inhibit by disabling DMI?

Try to add this row inside your struts.xml file.
<constant name="struts.enable.DynamicMethodInvocation" value="false" />


On 7 March 2011 03:51, Danyun.Liu <da...@gmail.com> wrote:
> 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.
>
>



-- 
Maurizio Cucchiara

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org