2017-03-01 14 views
0

Authenticated user'sファーストネームと姓を表示したいとします。関連するコードセグメントをHeader.jspに入れ、他の2つのJSPページ、Index.jspおよびNews.jspに含めます。<sec:authorizeは一部のJSPページでは機能しません。

News.jspに含まれるHeader.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> 

<sec>と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で作業しますか?

答えて

0

Index.jspでは、認証されたユーザーが必要ではなく、News.jspが実行する必要はありませんか?

関連する問題