码迷,mamicode.com
首页 > 其他好文 > 详细

struts2中<s:form>的应用

时间:2014-09-09 10:30:48      阅读:469      评论:0      收藏:0      [点我收藏+]

标签:http   os   io   使用   java   ar   for   art   div   

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/admin/include/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>TShop商城系统演示站 - Powered by TShop</title>
<%@include file="/admin/include/script.jsp"%>
</head>
<body>
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>店铺</h3>
      <ul class="tab-base">
        <li><a href="JavaScript:void(0);" class="current"><span>基本设置</span></a></li>

      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <s:form action="addStoreSetting.action" method="post" id="form_email" name="settingForm" > 
    <input type="hidden" name="form_submit" value="ok" />
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label>开店申请:</label></td>
        </tr>
        <tr class="noborder">
        <input type="hidden" name=‘setting.id‘ value="<s:property value=‘setting.id‘/>" />
<input type="hidden" name=‘setting.name‘ value="store_allow_isuse" />
          <td class="vatop rowform onoff">
          <s:if test=‘setting.value == "1"‘>
            <label for="store_allow_isuse_1" class="cb-enable selected" title="开启"><span>开启</span></label>
            <label for="store_allow_isuse_0"class="cb-disable " title="关闭"><span>关闭</span></label>
          </s:if>
          <s:if test=‘setting.value == "0"‘>
          <label for="store_allow_isuse_1" class="cb-enable " title="开启"><span>开启</span></label>
            <label for="store_allow_isuse_0"class="cb-disable selected" title="关闭"><span>关闭</span></label>
          </s:if>
            <input type="radio" id="store_allow_isuse_1" name="setting.value" value="1" <s:if test=‘setting.value == "1"‘>checked="checked"</s:if>>
            <input type="radio" id="store_allow_isuse_0" name="setting.value" value="0" <s:if test=‘setting.value == "0"‘>checked="checked"</s:if>>
            </td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2"><table class="table tb-type2 nomargin">
              <thead>
                <tr class="space">
                  <th colspan="16">信誉额度</th>
                </tr>
                <tr class="thead">
                  <th>等级</th>
                  <th>信用介于</th>
                </tr>
              </thead>
              <tbody>
              <s:if test="ruleList.size()>0">
              <s:iterator value="ruleList" status="status">                  
             <s:hidden   label="id" name="ruleList[%{#status.index}].id" value="%{ruleList[#status.index].id}"/> 
             <s:hidden  label="type" name="ruleList[%{#status.index}].type" value="%{ruleList[#status.index].type}"/> 
             <s:hidden  label="name" name="ruleList[%{#status.index}].name"  value="%{ruleList[#status.index].name}"/>
             <s:hidden  label="grade" name="ruleList[%{#status.index}].grade" value="%{ruleList[#status.index].grade}"/>
               <tr class="hover">
                 <td class="w200"><span class="<s:property value=‘name‘/> <s:property value=‘grade‘/>"><img src="http://121.52.216.217:10080/shopnc/admin/templates/images/transparent.gif"/></span></td>
                 <td>
                 <SPAN>
                 <s:textfield  name="ruleList[%{#status.index}].startValue"   value="%{ruleList[#status.index].startValue}"/>-&nbsp;&nbsp;<s:textfield  name="ruleList[%{#status.index}].endValue"  value="%{ruleList[#status.index].endValue}"/>
                 </SPAN>
                 </td>
                </tr>
                </s:iterator>
                </s:if>
              </tbody>
            </table></td>
        </tr>
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="2">
          <s:submit value="提交"  /> 
          </td>
        </tr>
      </tfoot>
    </table>
  </s:form>
</div>
</body>
</html>
 
注意:1、<s:form>表单中action属性action="addStoreSetting.action"不用写成 action="/admin/store/setting/addStoreSetting.action",struts2会自动匹配命名空间下的 addStoreSetting.action,还有就是非<s:form>表单的文本域写法也能通过<s:from>提交到后 台
2、由于使用struts2标签,页面样式受影响,所以需在struts2标签中加上theme="simple"才能够使原来的jsp页面样式不受影响。

struts2中<s:form>的应用

标签:http   os   io   使用   java   ar   for   art   div   

原文地址:http://www.cnblogs.com/plzdaye/p/3961230.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!