1

我在我的 tiles-defs.xml 中使用了 tiles 2.0

<definition name="user" extends="baseLayout">
  <put-attribute name="title" value="Share Admin user" />
  <put-attribute name="body" value="user.body" />
</definition>

<definition name="user.body" template="/WEB-INF/view/user.jsp">
  <put-attribute name="editingUserForm" value="/WEB-INF/view/userEditingModelFormModal.jsp"/>
</definition>

在我的 user.jsp 我有

<tiles:insertAttribute name="editingUserForm" />

当我加载我的用户页面时,我得到

org.apache.tiles.template.NoSuchAttributeException: Attribute 'editingUserForm' not found.

/WEB-INF/tiles/tiles-defs.xml

<bean id="viewResolver"
      class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="order" value="1" />
    <property name="viewClass">
        <value>
            org.springframework.web.servlet.view.tiles2.TilesView
        </value>
    </property>
</bean>

 @RequestMapping(method = RequestMethod.GET, value = "/admin/editingUser")
public String showAjaxEditingUser(Model model, @RequestParam("username") String userName) {

    UserBean userBean = userBeanMap.get(userName);
    model.addAttribute("editingUser", userBean);
    return "editingUserFormBodyPart";
}
4

0 回答 0