简体   繁体   中英

how can i use request parameter in struts2 if tag

i have a link like this : http://localhost:8080/ESA/login.jsp?login=failed in end of above link a set a parameter with name login and value failed .
how i can use this parameter in jsp page with struts if tag. I use following code but it don't work.

<s:if test="%{#parameters.login='failed'}">
    <div class="error">
        <s:text name="user.login.failed"></s:text>
    </div>
</s:if>

Try with

<s:if test="%{#parameters.login[0]=='failed'}">

The two problems were in your code:

  1. The = sign is an assignment, not equals == ;
  2. Parameters are saved in the Map<String, String[]> , so each parameter could have multiple values and accessed by the specifying an index.

    The last option also described here: why doesn't the if tag evaluate params properly .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM