实际上,我正在用jsp和servlet构建这个项目。下面是我遇到错误的代码:-
userdetails user=(userdetails)session.getattribute(“userd”)*
navbar.jsp
<nav class="navbar navbar-expand-lg navbar-dark bg-custom navbar-custom">
<a class="navbar-brand" href="#"><i class="fa fa-book"
aria-hidden="true"></i>ENotes</a>
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active"><a class="nav-link" href="index.jsp"><i
class="fa fa-home" aria-hidden="true"></i>Home <span
class="sr-only">(current)</span></a></li>
<li class="nav-item"><a class="nav-link" href="#"><i
class="fa fa-plus-circle" aria-hidden="true"></i>Add Notes</a></li>
<li class="nav-item"><a class="nav-link" href="#"><i
class="fa fa-address-book-o" aria-hidden="true"></i>Show Notes</a></li>
</ul>
<%
UserDetails user=(UserDetails)session.getAttribute("userD"); /*This is part where i'm getting error*/
if(user!=null)
{%>
<%}
else
{
}
%>
<a href="login.jsp" class="btn btn-light my-2 my-sm-0 mr-2"
type="submit"><i class="fa fa-sign-in" aria-hidden="true"></i>Login</a>
<a href="register.jsp" class="btn btn-light my-2 my-sm-0"
type="submit"><i class="fa fa-user-circle-o" aria-hidden="true"></i>Register</a>
<a href="login.jsp" class="btn btn-light my-2 my-sm-0 mr-2"
type="submit"><i class="fa fa-sign-in" aria-hidden="true"></i>Login</a>
<a href="register.jsp" class="btn btn-light my-2 my-sm-0"
type="submit"><i class="fa fa-user-circle-o" aria-hidden="true"></i>Register</a>
</div>
</nav>
如何解决这个问题?
1条答案
按热度按时间e3bfsja21#
似乎缺少导入,请将其添加到jsp