The moose likes Struts and the fly likes Cannot retrieve ID from GET method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Cannot retrieve ID from GET method" Watch "Cannot retrieve ID from GET method" New topic

Cannot retrieve ID from GET method

Fandy Akhmad
Ranch Hand

Joined: Nov 26, 2011
Posts: 32

Dear, master Java

I try to make CRUD Application using Struts2 , but there is problem while i edit data.
Problem is : Id cannot retrieve, its return 0(zero)

I get Id using this code (velocity) :

Then I try to ouput in console :

But Ouput : 0

This is my entity [] :

This my action []

And the last one my view, [view.vm]

Anyone, please help me,

Thanks before..
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Ha, interesting

1. You get 0 since your ID is of type int. May be you are not setting the value of Id. Where are you setting the value for this?
2. I guess "./view.action?id=$" would be taken as a single entity and does not evaluate the value of $ I didnt work in struts 2 and hence do not know exact conventions/syntax maybe try single quotes like "...?id='$'" - again this might work or may not, not sure.
3. ------------not at all important, but your code is very much vulnerable to SQL injection

Have Fun with Java
little,little.. little by little makes a lot..
I agree. Here's the link:
subject: Cannot retrieve ID from GET method
It's not a secret anymore!