项目中遇到问题及解决方案:
1,java.lang.ClassNotFoundException: 类名
严重: Servlet.service() for servlet [chloe.servlet.SSearchTransOfPage] in context with path [/SearchData] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: chloe.util.ResultSetToList 报错:
问题原因:WEB_INF的目录下没有对应的class文件;
解决方案:使得编译生成对应的class文件:https://blog.csdn.net/u011008029/article/details/49303723
2,java.lang.IllegalArgumentException 非法参数异常
JDBC原生方式访问数据库,得到的数据中,mysql表中定义为tinyInt(1)的数据值变成了boolean型;
解决方案:mysql的url路径后部署tinyInt1isBit=false ;注意,这个参数默认是true;另外的解决方案是 tinyInt(n) n>1
3,mysql的模糊查询;关键字 like not like; 条件中的值要加单引号括起来(''),并且使用字符匹配符% ,%表示0~n个字符;_表示一个字符;
4,原生JDBC得到的RusultSet转为List<自定义类> 参考
https://blog.csdn.net/yuyingting5/article/details/76229488
5,Jquery中的each循环中的return语句跳出当前的each循环,接着指向each之后的语句;要终止程序,两种解决方案;
方案一;设置flag;https://blog.csdn.net/luman1991/article/details/53698646
方案二:层层抛异常捕捉 https://blog.csdn.net/coffeesmile/article/details/53349860
6,No suitable driver found for jdbc
一:检查(Connection conn=DriverManager.getConnection(“jdbc:mysql://localhost:3306/XX”,”root”,”XXXX”)
二是:驱动字符串出错(com.mysql.jdbc.Driver)
三是Classpath中没有加入合适的mysql_jdbc驱动
7,JDBC连接数据库的方法:https://www.cnblogs.com/lihanxiang/p/8458020.html
8,HTML中的转义字符表:
9,JQuery选择select标签选中的值:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="../../../../js/common/jquery-1.6.2.js"></script>
<script type="text/javascript">
function doSome(){
alert($("#sel option:selected").text());//方法一:获取select标签选中的option中的文本。
alert($("#sel").find("option:selected").text());//方法二:获取select标签选中的option中的文本。
alert($("#sel option:selected").val());//方法一:获取select标签选中的option中的value的值。
alert($("#sel").find("option:selected").val());//方法二:获取select标签选中的option中的value的值。
//------------------------------帅气的分割线,,下面有重点--------------------------------
//当option是这样的:<option>cc</option>。即没有value属性的时候。自然也就没有value值。
//这时候jquery就很纠结:写了段代码让我拿value的值,可是找到的option中根本没有value属性。
//算了,把option中 的文本拿出来给你吧。
//所以当选中<option>cc</option>这个option的时候,你会发现上边四个alert出来的值是一样的。都是option中的文本。
//想要拿到option中的value的值,首先option得有value属性啊!!!
}
</script>
</head>
<body>
<div>
<select id="sel" οnchange="doSome();">
<option value="aa">bb</option>
<option>cc</option>
</select>
</div>
</body>
</html>
10,jquery获取input输入框中的输入值:
//jquery获取<input id="test" name="test" type="text"/>中输入的值?
$(" #test ").val()
$(" input[ name='test' ] ").val()
$(" input[ type='text' ] ").val()
$(" input[ type='text' ]").attr("value")
11,jquery的each中的function的参数:
index,下标索引,从0开始;
each的用法:https://blog.csdn.net/jingmeifeng/article/details/7763065点击打开链接
https://blog.csdn.net/sinat_21206105/article/details/53306768
12,jquery获取radio选中的值:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="" />
<style type="text/css"></style>
<script type="text/javascript" src="jquery-3.0.0.js"></script>
</head>
<body>
<input type="radio" name="radio" value="1" />1<br/>
<input type="radio" name="radio" value="2" />2<br/>
<input type="radio" name="radio" value="3" />3<br/>
<input type="radio" name="radio" value="4" />
<script type="text/javascript">
var a = $("input[name='radio']:checked").val();
alert("选中的radio的值是:" + a);
</script>
</body>
</html>
13,jquery获取子元素个数:
1 //获取id=div1下的子元素的个数
2 $('#id').children().length;
3 //获取id=div1下的p元素个数
4 $('#id').children('p').length;