【发布时间】:2017-07-20 20:14:33
【问题描述】:
我想显示Authenticated user's 名和姓。我把相关的代码段放在Header.jsp中,并包含在另外两个jsp页面Index.jsp和News.jsp中。
当Header.jsp 包含在News.jsp 中时,它可以正常工作并显示经过身份验证的用户的名字和姓氏,但是当它包含在Index.jspm 中时,它不会显示任何内容。
我的页面结构看起来很糟糕:
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>
索引.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>
在 Index.jsp 中不起作用的 <sec> 有什么问题?
【问题讨论】:
标签: java jsp spring-security