Jsp-三种赋值方式、include指令和动作元素的区别

一、三种赋值方式

1.value
说明:最直接的赋值方式

value赋值
id="ls" class="model.Employee" scope="session" /> property="id" name="ls" value="1002"/> property="name" name="ls" value="李四"/> property="departmentName" name="ls" value="人事部"/> 员工编号:property="id" name="ls"/>
员工姓名:property="name" name="ls" />
员工部门:property="departmentName" name="ls" />

2.param
说明:当name与属性名不相同的时候的赋值方式

<jsp:useBean id="employee" class="model.Employee" scope="session" />
<form action="<%=request.getContextPath()%>/jsp/test_getValue.jsp">
员工编号<input value="" name="id_text" /><br/>
员工姓名<input value="" name="name_text" /><br/>
员工部门<input value="" name="departmentName_text" /><br/>
<input type="submit" value="提交" />
form>
id="employee" class="model.Employee" scope="session" />
param赋值
property="id" name="employee" param="id_text"/> property="name" name="employee" param="name_text"/> property="departmentName" name="employee" param="departmentName_text"/> 员工编号:property="id" name="employee" />
员工姓名:property="name" name="employee" />
员工部门:property="departmentName" name="employee" />

3.*
说明:赋值所有name与属性名相同的值

<jsp:useBean id="employee" class="model.Employee" scope="session" />
<form action="<%=request.getContextPath()%>/jsp/test_getValue.jsp">
员工编号<input value="" name="id" /><br/>
员工姓名<input value="" name="name" /><br/>
员工部门<input value="" name="departmentName" /><br/>
<input type="submit" value="提交" />
form>
id="employee" class="model.Employee" scope="session" />
property="*" name="employee"/>

员工编号:property="id" name="employee" />
员工姓名:property="name" name="employee" />
员工部门:property="departmentName" name="employee" />

二、include指令和动作元素的区别

要求编码格式一致,不然会有乱码
1.include指令被称作静态include;include动作元素被称作动态include
2.include指令不可以传参,并且会报错;include动作元素可以
3.属性不一样,include指令是file;include动作元素是page、flush
4.include指令文件包含只生成一个servlet和class;include动作元素生成各自的servlet和class
5.引入时间不一样,include指令在启动的时候就引入了;include动作元素在触发的时候才会引入
6.include指令的两个文件共用一个request;include动作元素有两个request

你可能感兴趣的:(web后端)