zoukankan      html  css  js  c++  java
  • Struts标签中session判断jsp模块

     1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
     2 <%@ taglib prefix="s" uri="/struts-tags"%>
     3 
     4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     5 <html>
     6     <head>
     7         <title>My JSP 'login.jsp' starting page</title>
     8 
     9         <meta http-equiv="pragma" content="no-cache">
    10         <meta http-equiv="cache-control" content="no-cache">
    11         <meta http-equiv="expires" content="0">
    12 
    13     </head>
    14 
    15     <body>
    16     <s:if test="#session.username==null">
    17         <s:text name="struts.myssh.login"/>
    18         <hr>
    19         <s:form action="Login" method="post">
    20             ${log_err}
    21             <s:textfield name="username" key="struts.myssh.name" size="20" />
    22             <s:password name="password" key="struts.myssh.password" size="20" />
    23             <s:submit key="struts.myssh.login" />
    24         </s:form>
    25         </s:if>
    26         <s:else>
    27             ${session.username}
    28         </s:else>
    29     </body>
    30 </html>

    通过<s:if></if>标签判断session.username(用户名)是否存在,如果存在显示标签内的模块内容,如果不存在,显示<s:else></s:else>标签内的模块内容。

  • 相关阅读:
    Codeforces Beta Round #6 (Div. 2 Only)
    Codeforces Beta Round #5
    Codeforces Beta Round #4 (Div. 2 Only)
    Codeforces Beta Round #3
    Codeforces Beta Round #2
    Codeforces Beta Round #1
    HDU 4020 Ads Proposal
    SRM 615 DIV1 500
    求1+2+……+n(位运算)
    好好加油!
  • 原文地址:https://www.cnblogs.com/huanglibin/p/2792234.html
Copyright © 2011-2022 走看看