• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot retrieve ID from GET method

 
Ranch Hand
Posts: 32
MySQL Database Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Alas, poor Yorick, he knew this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic