web期末复习

DOM

var d1 = document.getElementById("id1");
var d2 = document.getElementsByName("name1")[0];
var d3 = document.getElementsByTagName("p")[1];
d1.innerHtml = "<p>1</p>";
d2.innerText = "你好";

String对象

var str = "123,abc";
str.charAt(1);
str.indexOf("ab");
str.substring(2,4);	//左闭右开
str.split(",")	
str.replace("aa","bb");	//注意只能替换一个

vat str1 = "122";
parseInt(str1);	// String -> Integer

Date对象

var now = new Date();
now.getFullYear();	//年
now.getMonth();	//月
now.getDate();	//日:下标从0开始
now.getDay();	//星期
now.getHours();	//小时
now.getMinutes(); //分钟
now.getSeconds(); //秒

MVC架构

  • 视图层(jsp页面)
  • 控制层(servlet)
  • 模型层(javabean)

Servlet

String name = request.getParameter("name");
String pwd = Integer.parseInt(request.getParameter("pwd"));
String[] list = request.getParameterValues("lis");

request.setAttribute("name");
String name = (String)request.getAttribute("name");

//请求转发
request.getRequestDispatcher("ck.jsp").forward(request,response);
//重定向
response.sendRedirect("ck.jsp");

Class.forName("org.h2.Driver");
// throw ClassNotfoundException,SQLException

Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(sql);
while(rs.next()!=null)
{
    
}

PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1,"name");
ps.setString(2,"pwd");
int res = ps.executeUpdate();

public class A extends HttpServlet
{
	
}
posted @ 2020-06-30 21:06  特立独行的猪猪  阅读(185)  评论(0编辑  收藏  举报