我有一个基本图块定义为:
<definition name="base_layout" template="/jsp/tools_tiles_layout.jsp">
<put-attribute name="body1" value="" />
<put-attribute name="body2" value="" />
</definition>
一页定义为:
<definition name="tool_Home" extends="base_layout">
<put-attribute name="body1" value="/jsp/default/tool_body/list1.jsp" />
<put-attribute name="body2" value="/jsp/default/tool_body/list2.jsp" />
</definition>
现在,我的一个控制器方法加载此页面,如:
@RequestMapping(value = "/test", method = RequestMethod.POST)
public String getListsById(Model model, String Id) {
List<String> list1 = null;
List<String> list2 = null;
try {
list1 = getList1FromDB();
list2 = getList2FromDB();
}
model.addAttribute("list1", list1);
model.addAttribute("list2", list2);
} catch (PersistenceException e) {
logger.error("error in ",e);
}
return "tool_Home";
}
现在我想在ajax调用之后只加载list2.jsp
$.ajax({
beforeSend: function(req) {
req.setRequestHeader("Accept", "text/html;type=ajax");
},
type : 'POST',
url : "./add?fragments=body2",
data : formData,
cache: false,
contentType: false,
processData: false,
datatype : "json",
beforeSend: function(req) {
req.setRequestHeader("Accept", "text/html;type=ajax");
},
complete : function(jqXHR)
{
$("#body2").html(jqXHR.responseText);
}
});
And my controller method for this Ajax Call is
______________________________________________
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String add(Model model, HttpServletRequest request) {
try {
List<String> list2 = getList2FromDB();
} catch (PersistenceException e) {
logger.error(e.getMessage(), e);
}
model.addAttribute("list2", list2);
return "tool_Home";
}
这是我的bean定义
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions" ref="TilesList"/>
</bean>
<bean id="TilesList" parent="parentTilesList">
<property name="sourceList">
<list merge="true">
<value>/WEB-INF/tiles.xml</value>
<value>/WEB-INF/tool-tiles.xml</value>
</list>
</property>
</bean>
但部分加载不起作用?我做错了什么?