SSH form表单提交到action的两种方式

第一种方式

  1. 在实体类中定义变量(例如变量:ENAME,JOB)
  2. 在action类中创建对象(例如:对象emp)
  3. 在jsp页面传值用 对象. 的方式
		name="emp.ENAME" value="${emp.ENAME}" 

实体类:

    public class Emp{
		private String ENAME;
		private String JOB;
    }

action类:

public class EmpSelfAction{
	private Emp emp=new Emp();
	public String editConfig(){
		System.out.println(emp.getENAME());
		System.out.println(emp.getJOB());
		return SUCCESS;
	}
}

jsp页面进行接收Action传来的值:

<tr>
	<th>员工姓名 </th>
		  <td style="text-align: center; white-space: nowrap;" width="50%">
		  <input name="emp.ENAME" value="${emp.ENAME}" style="width: 100%; height: 100%;border:0pt; background-color:white;" />
		</td>
	</tr>
		<tr>
		<th>职位</th>
     		<td style="text-align: center; white-space: nowrap;" width="50%">
		    <input name="emp.JOB" value="${emp.JOB}" style="width: 100%; height: 100%;border:0pt; background-color:white;" />
		</td>
	</tr>

第二种方式

  1. 在action中定义属性(例如:ENAME,JOB(该属性可以是实体类中的属性,也可以是新定义的))
  2. 在jsp页面把属性传进去。(例如: name=“ENAME” value="${ENAME}")
	 name="ENAME" value="${ENAME}"

action类:

public class EmpSelfAction{
private String ENAME;
private String JOB;
	public String editConfig(){
		System.out.println(ENAME);
		System.out.println(JOB);
		return SUCCESS;
	}
}

jsp页面进行接收Action传来的值:

<tr>
	<th>员工姓名 </th>
		  <td style="text-align: center; white-space: nowrap;" width="50%">
		  <input name="ENAME" value="${ENAME}" style="width: 100%; height: 100%;border:0pt; background-color:white;" />
		</td>
	</tr>
		<tr>
		<th>职位</th>
     		<td style="text-align: center; white-space: nowrap;" width="50%">
		    <input name="JOB" value="${JOB}" style="width: 100%; height: 100%;border:0pt; background-color:white;" />
		</td>
	</tr>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值