表单提交到struts2 和表单提交到springmvc的controller

我们直接上例子吧。

<form id="sampleform" method="post" action="addstore.html">
<fieldset>

<p>
<label class="required" for="name">名称:</label><br /> <input
type="text" id="name" class="half" name="storeInfo.name"
οnblur="checkName(id);" />
</p>

<p>
<label class="required" for="mallStatus">店铺类别:</label><br /> <select
id="mallStatus" class="input-text" style="width: 180px;"
name="storeInfo.mallStatus">
<s:iterator value="mallstatus" var="temp">
<option value="${temp }">${temp.value }</option>
</s:iterator>
</select>
</p>

<p>
<label class="required">所属频道:</label><br /> <select
class="input-text" name="storeInfo.channel" style="width: 180px;">
<option value="10">频道</option>

</select>
</p>


<p>
<label class="required" for="address">公司地址:</label><br />
<table>
<tr>
<td><select name="new_province" id="new_province"
class="ordslt" οnchange="changeprovice()"><option
value="0">请选择...</option>
<s:iterator value="catalogAddressOneList" var="var">
<option value="${var.id }">${var.name }</option>
</s:iterator>
</select>
</tr>

</table>
</p>



<p>
<label class="required">是否vip:</label><br /> <input type="radio"
id="isVip1" class="" value="false" name="storeInfo.vip"
checked="checked" /> <label class="choice" for="dateformat1">否</label>
<input type="radio" id="isVip2" class="" value="true"
name="storeInfo.vip" /> <label class="choice" for="dateformat2">是</label>
</p>

<p class="box">
<input type="submit" class="btn btn-green big" value="确定" /> <input
type="reset" class="btn btn-green big" value="重置" /> <input
type="button" class="btn btn-green big" οnclick="goBack();"
value="返回" />
</p>


</fieldset>


</form>

我们看标红的。。数据库中应有StoreInfoEntity 并且该实体应该有标红的字段。

Action中只用 使用 private StoreInfoEntity storeInfo; 实现其get和set方法。

这里尤其看一下 select 和radio 中name的写法



在springmvc中 所有的字段名字跟实体属性的名字一样就可以,不需要使用store.name,直接使用name 即可。

接收使用 @ModelAttribute(value="storeInfo") StoreInfoEntity storeInfo



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值