大家都知道在使用tiles的时候要建立一个模板,在建立模板的时候要创建一个完整的页面如下:
< %@ page contentType ="text/html;charset=GBK" language ="java" % >
< %@ include file ="taglib.jsp" % >

< html >
< c:view >
< head >
         < meta http-equiv ="Content-Type" content ="text/html;charset=GBK" />
         < link href ="/css/style.css" rel ="stylesheet" type ="text/css" />
         < script type ="text/javascript" language ="javascript" src ="/js/Appclient.js" > </script>
         < script type ="text/javascript" language ="javascript" src ="/js/check.js" > </script>
</head>

< body >
     < tiles:insert attribute ="body" flush ="true" />
</body>
</c:view>
</html>
这个里面已经有view了,这个时候如果在其它页面用到这个模板的时候一定要注意:模板中已经有的html元素,调用模板的页面就不能再添加了,否则一直会报一个attribute "for" is not definded的警告,而且前台的数据不会提交到后台,调用模板的页面如下:
< %@ page language ="java" pageEncoding ="UTF-8"% >
< %@ include file ="/pages/include/taglib.jsp"% >
< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
< h:form >
   < h:outputLabel value ="用户名" />
   < h:inputText id ="username" value ="#{user.username}" />
   < h:message for ="username" />
   < BR >
   < h:outputLabel value ="密码" />
   < h:inputText id ="password" value ="#{user.password}" />
   < h:message for ="password" > </h:message>
   < BR >
   < h:commandButton value ="提交" action ="#{user.loginVerify}" />
</h:form>