1、action 相应请求 返回到客户端浏览器
jsp 页面中元素的形式 :
1、input (html元素)
2、struts标签 (struts元素)
struts 标签中的 name = "是你在struts-config 配置好的form表单" ,property ="是配置好表单中的属性值" ,如果你填写property 在表单中不存在就会报notfound 错误。
因为服务器会解析jsp页面代码,把struts标签 转换成 html识别的 input,property会解析成input 中的 name 值,如果没有在 from 表单中发现该名字,就会出错。
input 存Html 代码,它的 name 是可以 自己制定的,与struts无关,所以可以任意设定。它的值取决 它的value 。
此时页面中存在的没有struts标签,只有input。
2、由客户端发送请求到 action
action 可以是之前进来的,也可以是其他的。
是之前的,两个form相同,没有什么问题。
是其他的,两个form配置的不同,会是什么样的呢?
提交表单后,页面所有的元素(例如 input)都会传给服务器,当通过action时候要封装配置的form,由页面来的 元素会自动去和 该form匹配,名字一样的会自动赋值过去,不一样的就不会赋值。不用担心form不匹配所有的元素会报错,同时这么值还会存在request中,可以通过parameter获取。
例如就有这样的
<action path="/vacancyList"
type="com.VacancyGridAction"
name="[color=red]vacancyGridForm[/color]" scope="request">
<forward name="vacancyList" path="vacancyList" />
</action>
|
\ /
<td ><input type="checkbox" name="aaaa" value=""/></td>
<td ><bean:write name="vacancyGridForm" property="standardSalePrice" /></td>
页面不会因为checkbox 的名字aaa 不存在vacancyGridForm中而出错
|
\ / 提交
<action path="[color=red]/vacancyView[/color]"
type="comVacancyAction"
name="[color=red]vacancyForm[/color]" scope="request">
<forward name="vacancyView" path="vacancyView" />
</action>
不会因为vacancyForm不存在standardSalePrice,aaaa而报错,他们存在只会自动匹配,不存在不赋值罢了。
而可以用 request.getParameter("aaaa");
request.getParameter("standardSalePrice"); 获取
jsp 页面中元素的形式 :
1、input (html元素)
2、struts标签 (struts元素)
struts 标签中的 name = "是你在struts-config 配置好的form表单" ,property ="是配置好表单中的属性值" ,如果你填写property 在表单中不存在就会报notfound 错误。
因为服务器会解析jsp页面代码,把struts标签 转换成 html识别的 input,property会解析成input 中的 name 值,如果没有在 from 表单中发现该名字,就会出错。
input 存Html 代码,它的 name 是可以 自己制定的,与struts无关,所以可以任意设定。它的值取决 它的value 。
此时页面中存在的没有struts标签,只有input。
2、由客户端发送请求到 action
action 可以是之前进来的,也可以是其他的。
是之前的,两个form相同,没有什么问题。
是其他的,两个form配置的不同,会是什么样的呢?
提交表单后,页面所有的元素(例如 input)都会传给服务器,当通过action时候要封装配置的form,由页面来的 元素会自动去和 该form匹配,名字一样的会自动赋值过去,不一样的就不会赋值。不用担心form不匹配所有的元素会报错,同时这么值还会存在request中,可以通过parameter获取。
例如就有这样的
<action path="/vacancyList"
type="com.VacancyGridAction"
name="[color=red]vacancyGridForm[/color]" scope="request">
<forward name="vacancyList" path="vacancyList" />
</action>
|
\ /
<td ><input type="checkbox" name="aaaa" value=""/></td>
<td ><bean:write name="vacancyGridForm" property="standardSalePrice" /></td>
页面不会因为checkbox 的名字aaa 不存在vacancyGridForm中而出错
|
\ / 提交
<action path="[color=red]/vacancyView[/color]"
type="comVacancyAction"
name="[color=red]vacancyForm[/color]" scope="request">
<forward name="vacancyView" path="vacancyView" />
</action>
不会因为vacancyForm不存在standardSalePrice,aaaa而报错,他们存在只会自动匹配,不存在不赋值罢了。
而可以用 request.getParameter("aaaa");
request.getParameter("standardSalePrice"); 获取