如何将字符串变量放在 URL 之间 URl 之间 JSP 之间?

How to put a string variable in between URL in between URl in JSP?

其实我用session.getAttribute得到了一个字符串,存到一个叫uname的变量里。现在我想在超链接之间使用此变量,以便登录的用户名显示为超链接。我试过以下,但它显示错误。在此先感谢您的帮助。

<%String uname=(String)session.getAttribute("uname");%>

  • <%=uname%> 的帐户
  • <%=uname%> 的帐户是这里的错误。没看懂,这里怎么显示用户名

    不要使用 scriptlet。

    您可以使用 JSP 表达式语言。

    <--There is bean in some scope with the key 'uname' -->
    <a href="/xyz">${uname}</a>
    
    <--There is bean in some scope with the key 'user' 
       and it is an instance of a class which has a method getUserName() -->
    <a href="/xyz">${user.userName}</a>