struts2+spring3: passing a variable from action to jsp (javascript code)
-
29-10-2019 - |
Pergunta
First of all, thank you very much to all these that are trying to solve our problems in this forum;)
I am developing a web application with struts2+spring3. And I have a question about how to pass a variable (an array of arrays) from the action class to the jsp page.
I know that the only you need to do is to declare a private variable in my action and a get method for that variable and then its possible to access these variable from the jsp, I have done it and it works.
public class Workspace extends ActionSupport {
private String[][] objects=null;
public String[][] getObjects() {
return objects;
}
public String execute() throws Exception{
The problem is that I want to access to this variable from the javascript code before loading the whole web page.
I have tried by different ways but it is never working.
$(function() {
var objectsMap=new Array();
$(document).ready(function() {
objectsMap = $objects;
});
neither works (the alert says: "Value: undefined"):
<s:set name="auxObj" value="%{objects}"/>
<script>
alert("Value: "+$("#auxObj").val());
</script>
Anyone have idea about how could I do that?
Nenhuma solução correta