Struts 2 no longer supports Using JSP El expressions in struts tags

Source: Internet
Author: User

When you use struts 2 tags, if you use the code:

<S: Set Name = "name" value = "<% =" '"+ request. getparameter (" name ") +"' "%>"/>

Or

<S: Set Name = "name" value = "$ {Param. name}"/>

The following errors will occur:

According to TLD or attribute directive in Tag file, attribute value does not accept any expressions

However, you must use:

<S: Set Name = "name" value = "# parameters. name [0]"/>

Yes

This may be because you have used the <% .. %> code or JSP El expression.Struts 2 does not support mixed use of struts tag and JSP El expression since version 2.0.11 (it is still possible not to use el in struts tag ), and only support ognl (about ognl introduction of the Chinese connection: http://www.blogjava.net/max/archive/2007/04/28/114417.html ).

Reason see: http://struts.apache.org/2.0.11/docs/release-notes-2011.html

Http://www.javaeye.com/news/193

Related discussions include:

Http://www.nabble.com/AppFuse-Struts-2-Basic-%2B-Hibernate---upgrade-to-AppFuse-2.0.1--%3E-Struts-Taglib-problem--td14749012s2369.html

Http://issues.appfuse.org/browse/APF-941

Http://www.nabble.com/Update-from-2.0.9-to-2.0.11-td14594912.html

Trick tip:

For <s: Property>

<S: property value = "# parameters. Name"/>

For <s: Set>, use (otherwise, an error occurs ):

<S: Set Name = "name" value = "# parameters. name [0]"/>

However, if you use the struts include tag to transmit parameters, <s: Property> and <s: Set> cannot obtain transmitted parameters, for example:

<Body>
<S: Include value = "/welcome. jsp">
<S: Param name = "name"> Scott </S: param>
</S: Include>
</Body>

In webcome. jsp, the "name" parameter cannot be obtained through <s: Property> and <s: Set>:

<S: property value = "# parameters. Name"/>

<S: Set Name = "name" value = "# parameters. name [0]"/>

And can only be used

<% Request. getparameter ("name") %>

To obtain

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.