This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 - If test of parameter value

 
Gaurav Arora
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to Struts and just playing around with sample applications. I have a very simple jsp :


The jsp simply checks if a request parameter "id" has a value of 2 and then prints Yes or No accordingly. However, my jsp always prints no. Is there a right way to check for request parameter values? Should this check be in the Action instead of the jsp?
 
selvaraju sellamuthu
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is printed Id is: some value here. you can try below code.
 
Gaurav Arora
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried that already, doesn't work. :-/
 
Rahul Chau
Greenhorn
Posts: 1
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use the following instead:

<body>Id is : <s roperty value="%{#parameters.id[0]}" /><br /><s:if test="%{#parameters.id[0] == 2}">Yes</s:if><s:else>No</s:else>
</body>

The parameters are passed as an array Map<String,String[]> and not Map<String,String>
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The parameters are passed as an array Map<String,String[]> and not Map<String,String>

The reason behind this is we can pass multiple parameters with same name.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic