Here is the code of my knockout template:
<script type="text/html" id="row-extension-template">
{{each items}}
<tr class="tr_element">
<td><span>${name}</span></td>
</tr>
{{/each}}
</script>
This piece of code is embedded in my jsp file.
When I see the html source-code generated by the server is look like this:
<tr class="tr_element">
<t开发者_JS百科d><span></span></td>
</tr>
But I want this:
<tr class="tr_element">
<td><span>${name}</span></td>
</tr>
I want the text ${name}
to be written in the html generated. How can I do that with Spring-mvc?
I have solved with this:
<script type="text/html" id="row-extension-template">
{{each items}}
<tr class="tr_element">
<td><span><%="${name}"%></span></td>
</tr>
{{/each}}
</script>
That way when I see the html source code I get:
<tr class="tr_element">
<td><span>${name}</span></td>
</tr>
Your page is loaded by using a Controller and RequestMapping in Spring. Find the method annotated with @RequestMapping that corresponds with your page. You then need to add the name to the model within that method.
model.addAttribute("name", "Some Name Value");
http://static.springsource.org/spring/docs/2.5.x/reference/mvc.html
Write an object to the Model
with key name
, as in:
@RequestMapping("foo.do")
public String myHandler(Model model) {
String name = "something";
model.addAttribute("name", name);
return "foo";
}
精彩评论