我的想法是建立一个template页面:
<struts:html>
    <head>
        <struts:base />
        <title>
            <struts-template:attribute name="title"/>
        </title>
    </head>
    <body>
        <table width="778" border="0" cellspacing="0" cellpadding="0" align="center">
            <tr>
                <td align="center" bgcolor="#996666">
                <table width=776 border=0 cellpadding=0 cellspacing=0>
                    <tr>
                        <td colspan=3 background="" bgcolor=#ffffff>
                        <jsp:include page="/resources/jsp/头部.jsp" />
                        
                        <struts-template:includeSection name="bodySection">这里是占位符:应用编码在这里?</struts-template:includeSection>
                        <jsp:include page="/resources/jsp/尾部.jsp" />
                        </td>
                    </tr>
                </table>
                </td>
            </tr>
        </table>
    </body>
</struts:html>

解决方案 »

  1.   

    呵呵,我不知道struts的模版是否可以做的到阿?还有什么高招,请不吝指教!
      

  2.   

    我看到bea提供的标签库里面是可以做到的,但是我不想和这些商业化的公司绑定的太紧了!!呵呵
      

  3.   

    我是来学习的。struts我也正在看。先关注一下哈。UP
      

  4.   

    Struts的例子里jsp页面是这样生成的:
    <template:insert template='/chapterTemplate.jsp'>
      <template:put name='title' content='Templates' direct='true'/>
      <template:put name='header' content='/header.html' />
      <template:put name='sidebar' content='/sidebar.jsp' />
      <template:put name='content' content='/introduction.html'/>
      <template:put name='footer' content='/footer.html' />
    </template:insert>
    也就是说其中的content需要预先生成,这样一来的话,我就需要为了一个应用页面作一次应用实现,同时还要做一次页面框架(模版)的实现!这样太麻烦了!
    我的希望是:
    <template:insert template='/chapterTemplate.jsp'>
      <template:put name='title' content='Templates' direct='true'/>
      <template:put name='header' content='/header.html' />
      <template:put name='sidebar' content='/sidebar.jsp' />
      <template:put name='content'>
                 这里是实际应用的代码!!
      </template:put>
      <template:put name='footer' content='/footer.html' />
    </template:insert>
    不知道这样是否可行!
      

  5.   

    苦闷,为什么没有提供类似占位符之类的东西呢!!!content倒是可以直接插入消息,不过我总不能把整个页面做成一个string吧!
      

  6.   

    真的想那个骂一句脏话,不过咱们是文明人就算了:我准备结贴了,如果没有更好的解决方案。tiles那个东西虽然可能功能比较强,但是太复杂了,我觉得也没必要推荐了。至于刚才我一直困惑的问题,我测试了一下,发现竟然是可以这么用的!真是佩服的五体投地!当然不是佩服我,而是佩服struts啦!
    <template:insert template='/chapterTemplate.jsp'>
      <template:put name='title' content='Templates' direct='true'/>
      <template:put name='header' content='/header.html' />
      <template:put name='sidebar' content='/sidebar.jsp' />
      <template:put name='content'>
                 这里是实际应用的代码!!
      </template:put>
      <template:put name='footer' content='/footer.html' />
    </template:insert>
    这种方法在bea的workshop 测试通过,我要去试试其他的服务器!明天结贴!