我想显示Authenticated user's
名字和姓氏。我将相关的代码段放在Header.jsp中,并将其包含在另外两个jsp页面Index.jsp
和News.jsp
中。
当Header.jsp
中包含News.jsp
时,它会正常显示并显示经过身份验证的用户的名字和姓氏,但是当它包含在Index.jsp
m时,它就不会什么都没有。
我的页面结构看起来像打击:
header.jsp中
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div class="usertext">
<span id="loginedUserFullname">
<sec:authorize access="isAuthenticated()">
<sec:authentication property="principal.firstname" />
<sec:authentication property="principal.lastname" />
<span class="welcome">welcome</span>
<a class="logout" href='/view/cpanel/Logout.jsp'>(loge out)</a>
</sec:authorize>
</span>
</div>
</nav>
的index.jsp
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content="">
<meta name="description" content="">
<jsp:include page="/includes/front/Head.jsp"></jsp:include>
<title></title>
</head>
<body>
<jsp:include page="/includes/front/Header.jsp"></jsp:include>
<jsp:include page="/includes/front/Scripts.jsp"></jsp:include>
</body>
News.jsp
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content="">
<meta name="description" content="">
<jsp:include page="/includes/front/Head.jsp"></jsp:include>
<title></title>
</head>
<body>
<jsp:include page="/includes/front/Header.jsp"></jsp:include>
<jsp:include page="/includes/front/Scripts.jsp"></jsp:include>
</body>
在{。{1}}中哪些在Index.jsp中无效?
答案 0 :(得分:0)
Index.jsp是否可能不要求用户进行身份验证但News.jsp有效?