我的网页有一个像
这样的导航栏
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<c:out value="${pageContext.request.remoteUser}"/>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="#" onclick="document.getElementById('logout-form').submit();">Logout</a>
</li>
</ul>
</li>
</ul>
现在,当我点击下拉菜单而不是向我显示Logout选项时,没有任何反应,它只是在网址上附加了一个“#”。例如,usr是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">
<div class="container-fluid">
<!-- 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="#bs-example-navbar-collapse-1">
<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="#"><img src="/static/images/Snapdeal.png"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" /> -->
<form id="logout-form" class="form-inline" action="/logout" style="display: none">
<input type="submit" value="Logout" class="btn btn-link" />
</form>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<h3 class="navbar-text"><b>Crux Admin</b></h3>
<ul class="nav navbar-nav">
<c:choose>
<c:when test="${param.currentPage eq 'dashboard'}">
<c:set var="classValue" value="active" />
</c:when>
<c:otherwise>
<c:set var="classValue" value="" />
</c:otherwise>
</c:choose>
<li class="${classValue}"><a href="/index">Dashboard</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<c:out value="${pageContext.request.remoteUser}"/>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="#" onclick="document.getElementById('logout-form').submit();">Logout</a>
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
答案 0 :(得分:0)
在您的网页的一部分添加此行,它将起作用
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>