2016-06-07 155 views
0

不工作我有有一个像下拉菜单中引导

<ul class="nav navbar-nav navbar-right"> 
 
\t \t \t \t <li class="dropdown"> 
 
\t \t \t \t \t <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> 
 
\t \t \t \t \t \t <c:out value="${pageContext.request.remoteUser}"/> 
 
\t \t \t \t \t \t <span class="caret"></span> 
 
\t \t \t \t \t </a> 
 
\t \t \t \t \t <ul class="dropdown-menu" role="menu"> 
 
\t \t \t \t \t \t <li> 
 
\t \t \t \t \t \t \t <a href="#" onclick="document.getElementById('logout-form').submit();">Logout</a> \t 
 
\t \t \t \t \t \t </li> 
 
\t \t \t \t \t </ul> 
 
\t \t \t \t </li> 
 
\t \t \t </ul>

现在,当我点击下拉菜单,而不是向我展示选项的导航栏网页注销没有任何反应,它只是附加一个“#”的URL。例如,美元是http://localhost:8080/index它变成http://localhost:8080/index#。我怎样才能避免这种

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
 
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> 
 
<nav class="navbar navbar-default navbar-static-top"> 
 
\t \t <div class="container-fluid"> 
 
\t \t \t <!-- Brand and toggle get grouped for better mobile display --> 
 
\t \t <div class="navbar-header"> 
 
\t \t \t <button type="button" class="navbar-toggle collapsed" 
 
\t \t \t \t data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 
 
\t \t \t \t <span class="sr-only">Toggle navigation</span> <span 
 
\t \t \t \t \t class="icon-bar"></span> <span class="icon-bar"></span> <span 
 
\t \t \t \t \t class="icon-bar"></span> 
 
\t \t \t </button> 
 
\t \t \t <a class="navbar-brand" href="#"><img src="/static/images/Snapdeal.png"></a> 
 
\t \t </div> 
 
\t \t <!-- Collect the nav links, forms, and other content for toggling 
 
\t \t <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" /> --> 
 
\t \t <form id="logout-form" class="form-inline" action="/logout" style="display: none"> 
 
\t \t \t <input type="submit" value="Logout" class="btn btn-link" /> 
 
\t \t \t 
 
\t \t </form> 
 
\t \t <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
 
\t \t \t <h3 class="navbar-text"><b>Crux Admin</b></h3> 
 
\t \t \t <ul class="nav navbar-nav"> 
 
\t \t \t \t <c:choose> 
 
\t \t \t \t \t <c:when test="${param.currentPage eq 'dashboard'}"> 
 
\t \t \t \t \t \t <c:set var="classValue" value="active" /> 
 
\t \t \t \t \t </c:when> 
 
\t \t \t \t \t <c:otherwise> 
 
\t \t \t \t \t \t <c:set var="classValue" value="" /> 
 
\t \t \t \t \t </c:otherwise> 
 
\t \t \t \t </c:choose> 
 
\t \t \t \t <li class="${classValue}"><a href="/index">Dashboard</a></li> 
 
\t \t \t </ul> 
 
\t \t \t 
 
\t \t \t 
 
\t \t \t <ul class="nav navbar-nav navbar-right"> 
 
\t \t \t \t <li class="dropdown"> 
 
\t \t \t \t \t <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> 
 
\t \t \t \t \t \t <c:out value="${pageContext.request.remoteUser}"/> 
 
\t \t \t \t \t \t <span class="caret"></span> 
 
\t \t \t \t \t </a> 
 
\t \t \t \t \t <ul class="dropdown-menu" role="menu"> 
 
\t \t \t \t \t \t <li> 
 
\t \t \t \t \t \t \t <a href="#" onclick="document.getElementById('logout-form').submit();">Logout</a> \t 
 
\t \t \t \t \t \t </li> 
 
\t \t \t \t \t </ul> 
 
\t \t \t \t </li> 
 
\t \t \t </ul> 
 
\t \t </div> 
 
\t \t <!-- /.navbar-collapse --> 
 
\t </div> 
 
\t <!-- /.container-fluid --> 
 
</nav>
这是整个页面

+0

你有ID的元素' #logout-form'在你的页面上?您没有提供足够的代码来重现您描述的问题。 – Serlite

+0

@Serlite我已把整个页面 –

+0

忽略此,评论,它不会让我删除它 – njfife

回答

0

添加在乌尔页面的一部分这一行,它会工作

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>