当前位置: 代码迷 >> Web前端 >> ognl简略标签
  详细解决方案

ognl简略标签

热度:1386   发布时间:2013-02-26 00:00:00.0
ognl简单标签
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">   
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
  </head>
 
  <body>
   <h1>登陆页面</h1>
   <form action="login">
   姓名:<input type="text" name="user.name"/><br/>
   密码:<input type="password" name="user.pwd"/><br/>
   <input type="submit" value="登陆"/>
   </form>
   <s:textarea name="personal" cols="10" rows="5" label="个人简历"></s:textarea>
   <h3>使用name和list属性,list属性的值是一个列表</h3>

<s:form>

    <s:select label="最高学历" name="education" list="{'高中','大学','硕士','博士'}"/>

</s:form>
<h3>使用name和list属性,list属性的值是一个Map</h3>

<s:form>

    <s:select label="最高学历" name="education" list="#{1:'高中',2:'大学',3:'硕士',4:'博士'}"/>

</s:form>
<h3>使用headerKey和headerValue属性设置header选项</h3>

<s:form>

    <s:select label="最高学历" name="education" list="{'高中','大学','硕士','博士'}"

       headerKey="-1" headerValue="请选择您的学历"/>

</s:form>
<h3>使用emptyOption属性在header选项后添加一个空的选项</h3>

<s:form>

    <s:select label="最高学历" name="education" list="{'高中','大学','硕士','博士'}"

       headerKey="-1" headerValue="请选择您的学历"

       emptyOption="true"/>

</s:form>

<h3>使用multiple属性设置多选</h3>

<s:form>

    <s:select label="最高学历" name="education" list="{'高中','大学','硕士','博士'}"

       headerKey="-1" headerValue="请选择您的学历"

       emptyOption="true"

       multiple="true"/>

</s:form>
<h3>使用size属性设置下拉框可显示的选项个数</h3>

<s:form>

    <s:select label="最高学历" name="education" list="{'高中','大学','硕士','博士'}"

       headerKey="-1" headerValue="请选择您的学历"

       emptyOption="true"

       multiple="true" size="8"/>

</s:form>
实例:

<s:form name="test">

    <s:doubleselect label="请选择所在省市"

       name="province" list="{'四川省','山东省'}" doubleName="city"

       doubleList="top == '四川省' ? {'成都市', '绵阳市'} : {'济南市', '青岛市'}" />

</s:form>
<s:form>

    <s:checkboxlist name="interest" list="{'足球','篮球','排球','游泳'}" label="兴趣爱好"/>

</s:form>
<s:submit type="image" method="login" src="images/login.jpg"></s:submit>
实例2.<s:submit type="button" action="selectTag" method="login" label="登陆"></s:submit>

<s:form>

<!-- 使用简单集合来生成可上下移动选项的下拉选择框 -->

<s:updownselect name="a" label="请选择您喜欢的图书" labelposition="top"

    moveUpLabel="向上移动"

    list="{'Spring2.0宝典' , '轻量级J2EE企业应用实战' , 'JavaScript: The Definitive Guide'}"/>
    </s:form>
    例子:

<s:head/>

<s:form>

    <s:optiontransferselect

    label="最喜爱的图书"

        name="javaBook"

        list="{'《Java Web开发详解》', '《Struts 2深入详解》', '《Java快速入门》'}"

        doubleName="cBook"

        doubleList="{'《VC++深入详解》', '《C++ Primer》', '《C++程序设计语言》'}"/>

</s:form>
<s:form>

    <s:optiontransferselect

    label="最喜爱的图书"

        name="book1"

        leftTitle="Java图书"

        rightTitle="C/C++图书"

        list="{'《Java Web开发详解》', '《Struts 2深入详解》', '《Java快速入门》'}"

        headerKey="-1"

        headerValue="--- 请选择 ---"

        emptyOption="true"

        doubleName="book2"

        doubleList="{'《VC++深入详解》', '《C++ Primer》', '《C++程序设计语言》'}"

        doubleHeaderKey="-1"

        doubleHeaderValue="--- 请选择 ---"

        doubleEmptyOption="true"

        addToLeftLabel="向左移动"

        addToRightLabel="向右移动"

        addAllToLeftLabel="全部左移"

        addAllToRightLabel="全部右移"

        selectAllLabel="全部选择"

        leftUpLabel="向上移动"

        leftDownLabel="向下移动"

        rightUpLabel="向上移动"

        rightDownLabel="向下移动"/>

</s:form>
<%java.util.Date date = new java.util.Date(); %>
<%=date%>

<s:date name="time" format="" />

  </body>
</html>
  相关解决方案