Struts+ibatis-学习总结一
1查询并返回list
别名映射->实体类:resultClass
|
<select id=" selectAll" resultClass="AppLog">
select
ID as id,
TYPE as type,
DESCR as descr
from APP_LOG
where ID = #id#
</select>
|
List list = sqlMapper.queryForList("selectAll");
for (int i = 0; i < list.size(); i ) {
AppLog log = (AppLog) list.get(i);
//add your code here;
}
|
别名映射->Map类:resultClass
|
<select id=" selectAll" resultClass="java.util.HashMap">
select
ID as id,
TYPE as type,
DESCR as descr
from APP_LOG
where ID = #id#
</select>
|
List list = sqlMapper.queryForList("selectAll");
for (int i = 0; i < list.size(); i ) {
Map map = (Map) list.get(i);
String id = (String) map.get("id");
String type = (String) map.get("type");
String descr = (String) map.get("descr");
//add your code here;
}
|
显式映射->实体类:resultMap
|
<resultMap id="AppLogResult" class="AppLog">
<result property="id" column="ID"/>
<result property="type" column="Type"/>
<result property="descr" column="DESCR"/>
</resultMap>
<select id="selectAll" resultMap="AppLogResult">
select * from APP_LOG
</select>
|
List list = sqlMapper.queryForList("selectAll");
for (int i = 0; i < list.size(); i ) {
AppLog log = (AppLog) list.get(i);
//add your code here;
}
|
显式映射->Map类:resultMap
|
<resultMap id="map-result" class="java.util.HashMap">
<result property="id" column="ID"/>
<result property="type" column="Type"/>
<result property="descr" column="DESCR"/>
</resultMap>
<select id="selectAll2" resultMap="map-result">
select * from APP_LOG
</select>
|
List list = sqlMapper.queryForList("selectAll2");
for (int i = 0; i < list.size(); i ) {
Map map = (Map) list.get(i);
String id = (String) map.get("id");
String type = (String) map.get("type");
String descr = (String) map.get("descr");
}
|
2,Unknown tag (c:forEach) 未知的标签
需要在
<%@ page language="Java" import="java.util.*" pageEncoding="utf-8"%>下面加一句
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
3<c:foreach>
<c:forEach>标签,需要与el表达式联合使用
<c:forEach>标签的语法定义如下所示。
<c:forEach var="每个变量名字" items="要迭代的list" varStatus="每个对象的状态"
begin="循环从哪儿开始" end="循环到哪儿结束" step="循环的步长">
循环要输出的东西
</c:forEach>
例如
<table border="1">
<tr><th>用户名</th> <th>密码</th> <th>操作</th></tr>
<c:forEach var="userlist" items="${userlist}">
<tr><th>${userlist.username}</th>
<th>${userlist.password}</th>
<th><a href="">修改</a> <a href="">删除</a> </th></tr>
</c:forEach>
</table>
4、request.setAttribute()和request.getAttribute()
2、request.setAttribute()和request.getAttribute()
set.jsp:
- <%@page contentType="text/html; charset=GB2312"%>
- <html>
- <head>
- <title>
- set.jsp file
- </title>
- </head>
- <body style="
- <%
- request.setAttribute("name","心雨");
- %>
- <jsp:forward page="get.jsp"/>
- </body>
- </html>

get.jsp:
- <%@page contentType="text/html; charset=GB2312"%>
- <html>
- <head>
- <title>
- get.jsp file
- </title>
- </head>
- <body style="
- <%
- out.println("传递过来的参数是:"+request.getAttribute("name"));
- %>
- </body>
- </html>

request.setAttribute()和request.getAttribute()是配合<jsp:forward>或是include指令来实现的。
5 jsp:useBean------
@ page language""=gb2312%><jsp:useBean id="user" scope="page" class="com.jsp.ch3.TestBean"/>
<jsp:setProperty name="user" property="*"/>
或者用以下,param可以不填写,其中param对应的是提交页面的表单name
<jsp:setProperty property="userName" name="user" param="userName"/>
<jsp:setProperty property="password" name="user" param="password"/>
<jsp:setProperty property="age" name="user" param="age"/>
<html>
<body>
注册成功:<br>
<hr>
使用Bean的属性方法<br>
用户名: =%><br>
密码: =%><br>
年龄: =%><br>
<hr>
使用getProperty<br>
用户名:<jsp:getProperty name="user" property="userName"/><br>
密码: <jsp:getProperty name="user" property="password"/><br>
年龄: <jsp:getProperty name="user" property="age"/>
客户端名称:=%>
</body>
</html>
6 input的不可编辑
disabled="disabled" 是不可以用,只是显示,在Struts2中并不能get input对应id的值;
readonly="readonly" 只读,不可编辑,但是Struts2中能获取值;
7
1.首先尝试修改表中的字段是否允许为NULL或设置为自增时出现一下提示
2.在工具->选项->Desigers->取消勾选“组织保存要求重新创建表的更改”
8安装多个jdk,配置环境变量时候,没有切换成功
需要在path中调换下jdk的位置,要排在program/orcal/..什么的前面;
9,JSON中,java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher问题
使用JSON,在SERVLET或者STRUTS的ACTION中取得数据时,如果会出现异常:java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher
是因为需要的类没有找到,一般,是因为少导入了JAR包,
使用JSON时,除了要导入JSON网站上面下载的json-lib-2.2-jdk15.jar包之外,还必须有其它几个依赖包:commons-beanutils.jar,commons-httpclient.jar,commons-lang.jar,ezmorph.jar,morph-1.0.1.jar
这几个包也是需要导入的.如果缺少里面的:ezmorph.jar包,则即出现上述异常
commons系列的包,可在网站:http://www.docjar.com/上面搜索下载,其它包可下载网站如下:
http://json-lib.sourceforge.net/
http://ezmorph.sourceforge.net/
http://morph.sourceforge.NET/
by :http://blog.csdn.Net/hzqcsds/article/details/7190250
10 JavaWeb项目中没有错,但是项目上面显示一个红叉的解决办法
出现这个问题的原因是因为,eclipse/myeclipse的jdk编译版本与出现问题的项目JDK编译版本不一致所导致!
方法/步骤
- 1
先设置好jdk,需要确定 项目,eclipse/myeclipse,系统 用的是同一个版本的JDK,我系统中安装的JDK是1.7,所以我把eclipse的jdk成1.7
- 2
进入 windows---proferences---java--compiler设置编译出来的文件使用的格式是 1.7版本的 (设置成多少都行,只要兼容,并且与你项目的编译版本一直就可以,我这里统一设置成1.7)
- 3
进入项目--properties---java Compiler 把项目编译版本也设置成 1.7
- 4
进入项目--properties---Myeclipse---project Facets设置java文件的版本为 1.7
- 5
Struts+ibatis-学习总结一的更多相关文章
- 【web开发学习笔记】ibatis学习总结
ibatis学习总结 ibatis数据库配置文件 <?xml version="1.0" encoding="UTF-8" ?> <!DOCT ...
- struts 2学习笔记—初学struts 2
首先我学习了struts 1.x与struts 2的区别: 1.struts 1.x的控制器类必须从Action类继承. 2.struts 2的控制器类可以是一个普通的类,也可以是ActionSupp ...
- ibatis 学习笔记 3 - pfpfpfpfpf的专栏 - 博客频道 - CSDN.NET
body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...
- ibatis学习笔记(完整)
1. Ibatis是开源软件组织Apache推出的一种轻量级的对象关系映射(ORM)框架,和Hibernate.Toplink等在java编程的对象持久化方面深受开发人员欢迎. 对象关系映 ...
- Spring+Struts+Ibatis的配置
指定Spring配置文件位置 <context-param> <param-name>contextConfigLocation</param-name> < ...
- Struts入门学习(一)
刚开始学习框架的时候感觉很简单,都是用到javaEE的相关框架,自己就想研究源码,但是学了很久之后毫无头绪,所以还是扎扎实实学好Struts毕竟框架做起来要比自己写javaEE要简单,下面我们就来一步 ...
- Spring+struts+ibatis(一)环境准备工作
首先我们先了解几个jar包的作用和一些未曾见过的接口和类 xwork-2.0.7.jar XWork是一个标准的Command模式实现,并且完全从web层脱离出来.Xwork提供了很多核心功能:前端拦 ...
- struts2,spring,ibatis学习
1.1 什么是struts2? MVC思想给网站设计带来了巨大的好处,但是MVC毕竟只是一种思想,不同的程序员写出来的基于MVC思想的应用,风格可能不一样.影响程序的标准化,Struts是为了规范MV ...
- Struts 2学习笔记——拦截器相关
一.添加国际化支持 默认的struts-deault.xml文件中已经定义了国际化拦截器,内容如下 <!-定义国际化拦截器--> <interceptor name="i1 ...
- IBatis学习
(1)建立 SqlMap.config文件 <?xml version="1.0" encoding="utf-8" ?> <sqlMapCo ...
随机推荐
- 老男孩Python高级全栈开发工程师三期完整无加密带课件(共104天)
点击了解更多Python课程>>> 老男孩Python高级全栈开发工程师三期完整无加密带课件(共104天) 课程大纲 1.这一期比之前的Python培新课程增加了很多干货:Linux ...
- Linux 常用命令(三)
一.less --分页查看文件:方面查阅(编辑)大文件 说明:支持方向键盘和鼠标向上向下浏览 -N 显示行号 二.head --output the first part of files 默认显示 ...
- HDU:4185-Oil Skimming
Oil Skimming Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Proble ...
- Fiddler证书安装不成功
Fiddler 抓包https配置 提示creation of the root certificate was not successful 证书安装不成功 原文链接 在使用Fiddler抓包时,我 ...
- luogu2761 软件补丁问题
状压最短路 #include <iostream> #include <cstring> #include <cstdio> #include <queue& ...
- 大数据学习——sparkSql对接hive
1. 安装mysql 2. 上传.解压.重命名 2.1. 上传 在随便一台有hadoop环境的机器上上传安装文件 su - hadoop rz –y 2.2. 解压 解压缩:apache- ...
- 聊聊、Nginx 安装启动
首先说下安装 Nginx 的步骤: (1)window 下安装 进入 http://nginx.org/en/download.html 下载版本 Mainline version 或者 Stable ...
- [小技巧]使用set对列表去重,并保持列表原来顺序
- java反射的基本使用
反射机制是java中非常重要的功能,熟练使用反射功能对实际的开发有很大的帮助. 一,通过反射获取对象实例 使用的对象User package whroid.java.reflect; public c ...
- 【bzoj2339】[HNOI2011]卡农 dp+容斥原理
题目描述 题解 dp+容斥原理 先考虑有序数列的个数,然后除以$m!$即为集合的个数. 设$f[i]$表示选出$i$个集合作为满足条件的有序数列的方案数. 直接求$f[i]$较为困难,考虑容斥,满足条 ...