EL(表达式语言 ) jsp2.0新增的功能

来源:互联网 发布:apm2.8源码编译 编辑:程序博客网 时间:2024/05/21 17:18

  1:html

<!DOCTYPE html>
<html>
  <head>
    <title>param_value.html</title>
    <meta name="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <form action="print_demo1.jsp" method="post">
姓名:<input type="text" name="uname"><br> 
性别:<input type="radio" name="sex" value="男" checked>男&nbsp;
<input type="radio" name="sex" value="女">女<br>
城市:<select name="city">
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="深圳">深圳</option>
<option value="广州">广州</option>
<option value="西安">西安</option>
</select><br>
爱好:<input type="checkbox" name="inst" value="C语言">c语言&nbsp; 
<input type="checkbox" name="inst" value="c++语言">c++语言&nbsp;
<input type="checkbox" name="inst" value="c#语言">c#语言&nbsp; 
<input type="checkbox" name="inst" value="object-c语言">object-c语言&nbsp;
    <input type="checkbox" name="inst" value="ASP.NET语言">ASP.NET语言<br>
自我介绍:<textarea cols="30" rows="3" name="note"></textarea><br> 
  <input type="submit" value="提交"><br />
  <input type="reset" value="重置"><br />
</form>
  </body>
</html>


 2:jsp(el)  Param接受指定请求参数,接收一组请求参数paramValues

<%@ page contentType="text/html" language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML >
<html>
  <head>
    <title>el</title>
  </head>
  <body>
  <%--   <%
     request.setAttribute("name", "李兴华");
     request.setAttribute("age", 32);
     request.setAttribute("job","高级工程师");
     %>
     姓名:<%=request.getAttribute("name")%><br>
    年龄:<%=request.getAttribute("age")%><br>
    职位:<%=request.getAttribute("job")%><br>
     姓名:${name}<br>
    年龄:${age}<br>
    职位:${job}<br> --%>
    <%
     request.setCharacterEncoding("UTF-8");
      %>
     <h2 >姓名:${param.uname}</h2>
     <h2 >性别:${param.sex}</h2>
     <h2 >城市:${param.city}</h2>
           爱好:${paramValues.inst[0]}&nbsp;
         ${paramValues.inst[1]}&nbsp;
         ${paramValues.inst[2]}&nbsp;
       ${paramValues.inst[3]}&nbsp;
      ${paramValues.inst[4]}<br>
        <h2>自我介绍: ${param.note}</h2> 
  </body>
</html>

0 0
原创粉丝点击