• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Cannot retrieve ID from GET method

 
Ranch Hand
Posts: 32
MySQL Database Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 [Pegawai.java] :
http://pastebin.com/vwKaG86H

This my action [View.java]
http://pastebin.com/GZQT7fwd

And the last one my view, [view.vm]
http://pastebin.com/vhWxehjX

Anyone, please help me,

Thanks before..
 
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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=$emp.id" would be taken as a single entity and does not evaluate the value of $emp.id. I didnt work in struts 2 and hence do not know exact conventions/syntax maybe try single quotes like "...?id='$emp.is'" - again this might work or may not, not sure.
3. ------------not at all important, but your code is very much vulnerable to SQL injection

 
reply
    Bookmark Topic Watch Topic
  • New Topic