2012-09-07 1 views
2

특정 웹 콘텐츠 구조에서 페이지 세션을 설정하려면 어떻게해야합니까? 특정 구조체에 페이지를 할당하면 session이 있는지 여부를 확인하고 그렇지 않은 경우 확인합니다 암호 입력을 요청할 것입니다. 사용자는 암호를 입력해야합니다. 나는 또한 내가 완료 또는 취소 할 경우 세션을 파괴 할 것이다, 그래서 및 취소 버튼 다음, 마침을 추가 할 페이지 구조에서 특정 Liferay 웹 콘텐츠 구조체에 세션 설정

. 그리고이 후에 사용자가 페이지에 액세스하려고하면 다시 암호를 묻습니다.

웹 콘텐츠 템플릿 *.VM에서 처리하려고합니다.

구조 코드 :

<?xml version="1.0"?> 

<root> 
    <dynamic-element name="classified" type="list" index-type="" repeatable="false"> 
     <dynamic-element name="Yes" type="1" index-type="" repeatable="false" /> 
     <dynamic-element name="No" type="0" index-type="" repeatable="false"/> 
    </dynamic-element> 
    <dynamic-element name="content" type="text_area" index-type="" repeatable="false"/> 
</root> 

템플릿 코드 :이 아이디어 작업을 할 수있는 방법

#if($classified.getData() == "1") 
    #if($request.parameters.get('password') == "1234") 
     <p>$content.getData()</p> 
    #else 
     <h2>This is the second authentication verification</h2> 
     <p>Please enter your second password</p> 

     #set ($url = $request.get('render-url')) 

     <form action="$url" name="auth" method="POST"> 
      <label name="password">Password<span style="color:red">*</span></label> 
      <input type="password" name="password" /> 
      <input type="submit" /> 
     </form> 

     #if($request.parameters.get('password') != "1234") 
      <p>Please enter correct password</p> 
     #end 
    #end 
#else 
    <h2>This is not a classified page</h2> 
#end 

다음

내가 지금까지 만든 코드입니다.

답변

0

제 생각에는 사용자 세션을 확인할 서블릿 을 작성하면 세션이없는 경우 자동으로 로그인 포틀릿이있는 전용 페이지로 리디렉션됩니다. 사용자 을 실제로으로 인증하는 것은 Velocity 스크립트의 작업이 아닙니다 ...

+0

고맙습니다. 언급 한대로 서블릿을 만들 수있는 방법을 알고 싶습니다. 귀하의 접근 방식이 적합하다고 생각합니다. 이걸 도울 수 있니? –