读书笔记-3

1、resultMap配置
2、ibatis一对多配置
3、jquery笔记
1、resultMap配置
当<select resultMap="topic_data">
<resultMap id="topic_data">必须一一对应。
(1)<resultMap class="tblTopic" id="topic_data">
  		<result property="topicId" column="topicid"/>
  		<result property="title" column="title"/>
  		<result property="content" column="content"/>
  		<result property="publishTime" column="publishtime"/>
  		
  </resultMap>
  <select id="getTopics" parameterClass="java.lang.Integer" 	resultMap="topic_data">
  select topicid topicId, title title, 
  		content content, publishtime publishTime,  modifytime modifyTime  
  from tbl_topic where boardid=#boardid#
  </select> 
(2)错误的配置(modifytime在resultMap中配置,在select中就应该查询出)
 <resultMap class="tblTopic" id="topic_data">
  		<result property="topicId" column="topicid"/>
  		<result property="title" column="title"/>
  		<result property="content" column="content"/>
  		<result property="publishTime" column="publishtime"/>
  		<result property="modifyTime" column="modifytime"/>
  </resultMap>
  <select id="getTopics" parameterClass="java.lang.Integer" resultMap="topic_data">
  select topicid topicId, title title, 
  		content content, publishtime publishTime
  from tbl_topic where boardid=#boardid#
  </select> 
2、ibatis一对多配置
<resultMap id="board_data" class="tblBoard">
		<result property="boardId" column="boardid"/>
		<result property="boardName" column="boardname"/>
		<result property="parentId" column="parentid"/>
		<result property="topics" column="boardid" select="board_mapping.getTopics"/>
  </resultMap>
  
  <resultMap id="topic_data" class="tblTopic" >
  		<result property="topicId" column="topicid"/>
  		<result property="title" column="title"/>
  		<result property="content" column="content"/>
  		<result property="publishTime" column="publishtime"/>
  		<result property="modifyTime" column="modifytime"/>
  </resultMap>
  <select id="getTopics" parameterClass="java.lang.Integer" resultMap="topic_data">
  select topicid topicId, title title, 
  		content content, publishtime publishTime,  modifytime modifyTime  
  from tbl_topic where boardid=#boardid#
  </select> 
  <select id="getBoardById" parameterClass="java.lang.Integer" resultMap="board_data">
  	select boardid as "boardId",boardname as "boardName",parentid as "parentId" from tbl_board
		where boardid=#id#
  </select>
3、jquery笔记
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'register.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">
	-->
	<style type="text/css">
		.focus{
			border:1px solid #foo;
			background:#fcc;
		}
		.username{
			border:1px solid #foo;
			background:#fcd;
		}
		
	</style>
	<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
  </head>
  <script type="text/javascript">
  
	   $(document).ready(function(){
	  	  $(":input").focus(function(){//选中所有input、textarea、select、button
	  		$(this).addClass("focus");
	  	  }).blur(function(){
	  		$(this).removeClass("focus");
	  	  })
	    });
	  	function registerFun(){
	  		$(document).ready(function(){
	  			//alert($("#username").val());
	  		})
	  		$(document).ready(function(){
	  			//alert($("#password").val());
	  		})
	  		//jquery----dom
	  		//var $username=$("#username");//jquery对象
	  		//var username=$username[0];//dom对象-1
	  		//var username=$username.get(0);//dom对象-2
	  		//alert(username.value);
	  		//dom-----jquery
	  		var username=document.getElementById("username");//dom对象
	  		var $username =$(username);//jquery对象
	  		//alert($username.get(0).value);
	  		//获得name为sex选中的值
	  		//var $sex=$("input[name=sex]:checked");
	  		//alert($sex.get(0).value);
	  		//循环checkbox
	  		$("input[name=hobby]:checked").each(function(){
	  			//alert(this.value);
	  		})
	  		//select
	  		//alert($(".city").val());
	  		
	  		$("#street option:selected").each(function(){
	  			alert(this.value);
	  		})
	  	}
  </script>
  <body>
  <TABLE>
    	<form action="/register" id="frm" name="registerFrm">
    		<TR><TD>用户名:</TD><TD><input type="text" name="username" id="username" class="username"/></TD></TR>
    		<TR><TD>密码: </TD><TD><input type="text" name="password" id="password"/></TD></TR>
    		<TR><TD>性别:</TD><TD><input type="radio" name="sex" value="1"/>男<input type="radio" name="sex" value="0" />女</TD></TR>
    		<tr><td>爱好:</td><td><input type="checkbox" name="hobby" value="篮球 " />篮球<input type="checkbox" name="hobby" value="足球"/>足球<input type="checkbox" name="hobby" value="拍球"/>拍球</td></tr>
    		<tr><td>地区:</td><td>
    		<select id="dis" name="city" class="cityuu">
    				<option value="beijing">北京</option>
    				<option value="shanghai">上海</option>
    				<option value="nanjing">南京</option>
    				<option value="wuhan">武汉</option>
    		</select></td></tr>
    	    <tr><td>街道:</td><td>
	    		<select id="street" name="street" multiple>
	    				<option value="shunyi">顺义</option>
	    				<option value="chaoyang">朝阳</option>
	    				<option value="haidian">海淀</option>
	    		</select></td>
	    	</tr>
    		<tr>
	    		<td><input type="button" value="提交" onclick="registerFun()"/></td>
	    		<td><input type="reset" value="重置"/></td>
    		</tr>
    	</form>
   </TABLE>
  </body>
</html>

你可能感兴趣的:(jquery笔记,resultMap配置,ibatis一对多配置)