struts2标签举例(完整运行程序)

2018-03-30 12:18:15 浏览数 (3)

代码语言:javascript复制
   <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>  
   <%  
  String path = request.getContextPath();  
  String basePath = request.getScheme()   "://"  
    request.getServerName()   ":"   request.getServerPort()  
    path   "/";  
   %>  
   <%@taglib prefix="s" uri="/struts-tags"%>  
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
   <html>  
   <head>  
   <title>add student</title>  
   </head>  
   <body>  
  <s:form action="student">  
  <s:hidden name="action" />  
  <s:textfield name="stuNo" label="考生ID" cssStyle="width:128px;" />  
  <s:textfield name="name" label="姓名" cssStyle="width:128px;" />  
  <s:textfield name="email" label="EMAIL" cssStyle="width:128px;" />  
  <s:textfield name="address" label="地址" cssStyle="width:128px;" />  
  <s:textfield name="telphone" label="电话" cssStyle="width:128px;" />  
  <s:select name="studyHistory" label="学历" list="{'初中','高中','本科','硕士','博士'}"/>  
  <s:radio name="sex" label="性别" list="#{'male':'男', 'female':'女'}"/>  
  <s:checkboxlist name="interest" label="兴趣爱好" list="#{1:'棒球', 2:'羽毛球', 3:'乒乓球', 4:'篮球', 5:'足球'}"/>  
  <s:textarea row="5" cols="20" name="remark" label="备注信息" cssStyle="height:100px; width:500px;" />  
  </s:form>  
   <s:file name="pic" label="图片" accept="image/bmp,image/png,image/gif,image/jpeg,image/pjpeg" />  
    <s:updownselect name="books" label="请选择您想选择的书籍" labelposition="top"  
      moveUpLabel="up" moveDownLabel="down" selectAllLabel="all"  
      list="#{1:'Spring2.0宝典' ,2:'轻量级J2EE企业应用实战' ,3:'基于J2EE的Ajax宝典'}"  
      listKey="key" listValue="value" size="3" />  
    <s:optiontransferselect label="最喜爱的图书" name="javaBook"  
      list="{'《Java Web开发详解》', '《Struts 2深入详解》', '《Java快速入门》'}"  
      doubleName="cBook"  
      doubleList="{'《VC  深入详解》', '《C   Primer》', '《C  程序设计语言》'}" />  
     <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="向下移动" />  
   </body>  
   </html>  

0 人点赞