java - Passing a model to an included JSP? -


is there way me pass model jsp include <script/> tag?

i'm trying create dynamic javascript, , need model access object has set of properties need. i'm using liferay automagically include jsp, , i'm using spring controller.

controller:

@requestmapping public string showform( modelmap model ){ model.addattribute( "mykey", object ); return "myview"; } 

accessing ${mykey} myview.jsp works, how @ model included jsp?

a jsp include <script> tag? jsp represents dynamically populated text/javascript response? no, that's not possible. loaded separate http request won't contain same attributes request returned parent html page. not confused server-side includes using <jsp:include> take place within same http request.

apart putting in session scope (which can have more caveats want), best print necessary data global js variable.

<script>var foo = '${model.foo}';</script> <script src="script.jsp"></script> 

this way can access usual js way inside script.jsp.

i don't spring, in theory map spring controller on script.jsp own model (which same 1 in parent jsp, whenever necessary).


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -