您的位置:首页 > 其它

我的学习记录134

2018-02-21 09:05 218 查看
2018.2.21李锦浩【连续第134天】
昨天已经学习了如何利用动作指令来对javaBean进行实例化,今天需要学习如何对实例化的javaBean对象进行初始化。
<jsp:setProperty>格式:<jsp:setPropertyname=”javaBean实例名” property=”*”/>
<jsp:setProperty name=”javaBean实例名”property=”javaBean属性名”/>(以上两种跟表单关联)
<jsp:setProperty name=”javaBean实例名”property=”javaBean属性名”value=”BeanValue”/>(手工设置)
<jsp:setProperty name=”javaBean实例名”property=”javaBean属性名” param=”request对象中的参数名”/>(跟request参数关联)
附:<%@ page language="java" import="java.util.*"pageEncoding="utf-8"%><%Stringpath = request.getContextPath();StringbasePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%> <!DOCTYPE HTML PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'dologin.jsp' starting page</title>        <meta http-equiv="pragma"content="no-cache">    <meta http-equiv="cache-control"content="no-cache">    <meta http-equiv="expires"content="0">        <meta http-equiv="keywords"content="keyword1,keyword2,keyword3">    <meta http-equiv="description"content="This is my page">    <!--    <link rel="stylesheet"type="text/css" href="styles.css">    -->   </head>    <body>  <jsp:useBean id="myusers" class="javaBean.User"scope="page"/>    <h1>setProperty动作使用方法</h1>  <hr>  <!-- 根据表单匹配所有属性 -->  <jsp:setProperty property="*" name="myusers"/>    用户名:<%=myusers.getUsername() %>    密码:<%=myusers.getPassword() %>    <!-- 根据表单匹配部分属性 -->   <jsp:setProperty property="password" name="myusers"/>       用户名:<%=myusers.getUsername() %>    密码:<%=myusers.getPassword() %>  </body>
</html><%@ page language="java" import="java.util.*"pageEncoding="utf-8"%><%Stringpath = request.getContextPath();StringbasePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%> <!DOCTYPE HTML PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'login.jsp' starting page</title>        <meta http-equiv="pragma"content="no-cache">    <meta http-equiv="cache-control"content="no-cache">    <meta http-equiv="expires"content="0">        <meta http-equiv="keywords"content="keyword1,keyword2,keyword3">    <meta http-equiv="description"content="This is my page">    <!--    <link rel="stylesheet"type="text/css" href="styles.css">    -->   </head>    <body>  <h1>系统登录</h1>  <hr>  <form name="loginForm"action="dologin.jsp" method="post">  <table>     <tr>     <td>用户名</td>     <td><input type="text"name="username" value=""/></td>     </tr>     <tr>     <td>密码</td>     <td><input type="password"name="password" value=""/></td>     </tr>     <tr>     <td colspan="2"align="center"><input type="submit"value="登录"/></td>     </tr>  </table>  </form>  </body>
</html>
明日任务:继续学习javaweb。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: