java - Pass a foreach JSP variable as parameter to javascript function -


i have following code sample written in jsp. not working. have tried code snippet following links. didn't me solve problem.

pass jsp variable parameter javascript function

passing jsp variable javascript function parameter

< c:foreach items="${items}" var="item">

   <div onclick="myonclick('<%=item%>')">${item.title}</div> 

< /c>

function myonclick(item){     console.log(json.stringify(item)); } 

actually getting error in eclipse "item cannot resolved variable" jsp code.

i tried below 1 code

      <div onclick="myonclick(${item})">${item.title}</div> 

it throwing "syntax error:illegal character" error.

need fix issue. thank you.

i found answer own following link.

how access java object in javascript jsp?

that doing in code. getting java objects , mapping them html. once mapped wan unable access them javascript. in above link have provided solution problem. have call web service actual object. thank @leledumbo providing answer.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -