我只是想用 Spring MVC 学习 Tiles。我以前没用过瓷砖。请找到随附的代码:
servlet.xml
<context:component-scan base-package="org.sparsham.sparshammanagement.controllers" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.tiles2.TilesView" />
<property name="prefix" value="/WEB-INF/pages"/>
<property name="suffix" value=".jsp"></property>
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
我的 Tiles.xml
<tiles-definitions>
<definition name="base.definition" template="/WEB-INF/pages/layout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/pages/layout/header.jsp" />
<put-attribute name="menu" value="/WEB-INF/pages/layout/menu.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/pages/layout/footer.jsp" />
</definition>
</tiles-definitions>
然后我创建了布局页眉和页脚。
@Controller
@RequestMapping("/")
public class Default {
@RequestMapping("index")
public String index(){
return "Sparsham";
}
@RequestMapping("*")
public String unhandled(){
return "error404";
}
}
你下一步怎么做?