aspose file tools*
The moose likes Struts and the fly likes Struts 2 - If test of parameter value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 - If test of parameter value" Watch "Struts 2 - If test of parameter value" New topic
Author

Struts 2 - If test of parameter value

Gaurav Arora
Ranch Hand

Joined: Aug 13, 2007
Posts: 35
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

Joined: Jun 28, 2007
Posts: 53
If it is printed Id is: some value here. you can try below code.
Gaurav Arora
Ranch Hand

Joined: Aug 13, 2007
Posts: 35
Tried that already, doesn't work. :-/
Rahul Chau
Greenhorn

Joined: Jan 10, 2012
Posts: 1
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

Joined: Aug 01, 2007
Posts: 485

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.

ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2 - If test of parameter value