jsp:include删除页面的其余部分?

时间:2015-04-23 14:39:46

标签: jsp include

我有一个问题,当我使用

要么 页面的组件确实出现,但我刚刚消失的页面的其余部分 这是我的主页:               主页                             
<div class="subheader nospace tcenter">
    <h1>EasyScrum is the best</h1>
    <p>Description ..................................................</p>
    <button type="button"
        class="btn btn-default btn-lg btn-block homebutton">Get
        Started</button>
</div>
<div id="container" class="nospace tcenter">
    <h1>Some Text</h1>
    <p>Some Pictures down here</p>

    <div class="divider"></div>
    <br> <br> <br> <br> <br> <br> <br>
    <br> <br>
    <h1>Some Text</h1>
    <p>Some Pictures down here</p>

    <div class="divider"></div>
    <br> <br> <br> <br> <br> <br> <br>
    <br> <br>
    <h1>Some Text</h1>
    <p>Some Pictures down here</p>
    <button type="button"
        class="btn btn-default btn-lg btn-block homebutton">Hey look ! A            button</button>
</div>
<%@ include file="Component/footer.jsp" %>
</body>

这是我的其他页面

footer.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"     "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet"
href="/easyscrumweb/resources/css/CostumeStyle.css">
<title>Insert title here</title>
</head>
<body>
    <div id="footer">
    <footer class="norandomespace">
        <div class="footer" id="footer">
            <div class="container">
                <div class="row">
                    <div class="col-lg-2  col-md-2 col-sm-4 col-xs-6">
                        <h3>Head Quarter </h3>
                        <ul>
                            <li> <a href="#"> Link 1 </a> </li>
                            <li> <a href="#"> Link 1 </a> </li>
                            <li> <a href="#"> Link 1 </a> </li>
                            <li> <a href="#"> Link 1 </a> </li>
                        </ul>
                    </div>

                    <div class="col-lg-2  col-md-2 col-sm-4 col-xs-6">
                        <h3>Head Quarter </h3>
                        <ul>
                            <li> <a href="#"> Link 1 </a> </li>
                            <li> <a href="#"> Link 1 </a> </li>
                            <li> <a href="#"> Link 1 </a> </li>
                        </ul>
                    </div>
                    <div class="col-lg-3  col-md-3 col-sm-6 col-xs-12 ">
                        <h3> Lorem Ipsum </h3>
                        <ul>
                            <li>
                                <div class="input-append newsletter-box     text-center">
                                    <input type="text" class="full text-    center" placeholder="Email ">
                                    <button class="btn  bg-gray"     type="button"> Lorem ipsum <i class="fa fa-long-arrow-right"> </i> </button>
                                </div>
                            </li>
                        </ul>
                        <ul class="social">
                            <li> <a href="#"> <i class=" fa fa-facebook">       </i> </a> </li>
                            <li> <a href="#"> <i class="fa fa-twitter">   </i> </a> </li>
                            <li> <a href="#"> <i class="fa fa-google-plus">   </i> </a> </li>
                            <li> <a href="#"> <i class="fa fa-pinterest">   </i> </a> </li>
                            <li> <a href="#"> <i class="fa fa-youtube">   </i> </a> </li>
                        </ul>
                    </div>
                </div>
                <!--/.row--> 
            </div>
            <!--/.container--> 
        </div>
        <!--/.footer-->

        <div class="footer-bottom">
            <div class="container">
                <p class="pull-left"> Copyright © EasyScrum. All right reserved. </p>
                <div class="pull-right">
                    <ul class="nav nav-pills payments">
                        <li><i class="fa fa-cc-visa"></i></li>
                        <li><i class="fa fa-cc-mastercard"></i></li>
                        <li><i class="fa fa-cc-amex"></i></li>
                        <li><i class="fa fa-cc-paypal"></i></li>
                    </ul> 
                </div>
            </div>
        </div>
        <!--/.footer-bottom--> 
    </footer>
</div>
</body>
</html>

和pagemenu.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"     "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Home Page</title>
<link rel="stylesheet"
href="/easyscrumweb/resources/css/CostumeStyle.css">
</head>
<body>
<!-- Main navbar -->
<div id="header">
    <nav class="navbar navbar-inverse norandomespace">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed"
                    data-toggle="collapse" data-target="#navbar-collapse-4">
                    <span class="sr-only">Toggle navigation</span> <span
                        class="icon-bar"></span> <span class="icon-bar"></span> <span
                        class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">EasyScrum</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse membermenu" id="navbar-collapse-4">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">Home</a></li>
                    <li><a href="#">About</a></li>
                    <li><a href="#">Services</a></li>
                    <li><a href="#">Works</a></li>
                    <li><a href="#">News</a></li>
                    <li><a href="#">Contact</a></li>
                    <li><a
                        class="btn btn-default btn-outline btn-circle collapsed"
                        data-toggle="collapse" href="#nav-collapse4"
                        aria-expanded="false" aria-controls="nav-collapse4">Member Space <i
                            class=""></i>
                    </a></li>
                </ul>
                <ul class="collapse nav navbar-nav nav-collapse slide-down"
                    role="search" id="nav-collapse4">
                    <form class="navbar-form navbar-right form-inline memberli" role="form">
                      <div class="form-group">
                        <label class="sr-only" for="Email">Email</label>
                        <input type="email" class="form-control" id="Email" placeholder="Email" autofocus required />
                      </div>
                      <div class="form-group">`enter code here`
                        <label class="sr-only" for="Password">Password</label>
                        <input type="password" class="form-control" id="Password" placeholder="Password" required />
                      </div>
                      <button type="submit" class="btn btn-success">Sign in</button>
                      <div class="registerb"><a href="/easyscrumweb/register"><button type="button" class="btn btn-info">Sign up</button></a></div>
                    </form>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>
    <!-- /.navbar -->
</div>
<!-- /.container-fluid -->

</body>
</html>

ps:我试过只包含一页而且它没有工作:(

1 个答案:

答案 0 :(得分:0)

footer.jsp文件应该只包含特定于页脚的上下文,即:

之间的所有内容
<div id="footer">
    <footer class="norandomespace">
      <!-- and everything in between-->
    </footer>
</div>

您应该删除主页前后的所有内容:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"     "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet"
href="/easyscrumweb/resources/css/CostumeStyle.css">
<title>Insert title here</title>
</head>
<body>

   <!--Other content -->

   <%@ include file="Component/footer.jsp" %>
</body>
</html>