欢迎光临散文网 会员登陆 & 注册

手动建Java web项目的方法,JSP,DBUtils,MySQL,下拉框,form表单显示【诗书画唱】

2020-09-14 23:33 作者:诗书画唱  | 我要投稿

1、创建一个用户类型utype表,包含id和tname(用户类型名)字段,插入以下几条数据:

1 超级管理员

2 管理员

3 客户

4 商户

5 合作伙伴



通过jdbc编程将utype表中的tname拼接成一个下拉框显示在jsp页面上


create table utype

(

id int primary key auto_increment,



tname varchar(100) 



);


insert into utype(tname) values ("超级管理员"),('管理员' ),('客户' ),('商户' ),('合作伙伴' );

select * from utype


package com.SSHC.bean;


public class Utype {

    private Integer id;

    private String tname;

public Integer getId() {

return id;

}

public void setId(Integer id) {

this.id = id;

}

public String getTname() {

return tname;

}

public void setTname(String tname) {

this.tname = tname;

}


}

package com.SSHC.DAO;


import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;

import java.util.List;


import com.SSHC.bean.Utype;

import com.SSHC.util.DBUtils;

//DAO(Data Access Object)是一个数据访问接口,

//数据访问:顾名思义就是与数据库打交道。

//夹在业务逻辑与数据库资源中间。

///DAO就是实现增删改查的一个类

public class UtypeDao {

    //用XXXDao(XXX为表名比如Eduinfo),Eduinfo:教育信息。

///XXXDAO可查询eduinfo表中的所有的数据。

//List用上泛型:

public List<Utype>selectAll(){

String sql = "select * from Utype";

Connection conn = null;

PreparedStatement pstm = null;

ResultSet rs = null;

List<Utype>list = new ArrayList<Utype>();

try {

// 下面用上DBUtils(当然命名为Dbutil,也可以

// 自己知道是数据库常用工具就可以了:

conn = DBUtils.getConn();

pstm = conn.prepareStatement(sql);

rs = pstm.executeQuery();

while(rs.next()) {

Integer id = rs.getInt("id");

String ename = rs.getString("tname");

//进行打包:

Utype edu = new Utype();

edu.setId(id);

edu.setTname(ename);

//继续打包:

list.add(edu);

}

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return list;

}

public static void main(String[] args) {

UtypeDao ed = new UtypeDao();

List<Utype>list = ed.selectAll();

System.out.println(list.size());

}

}




package com.SSHC.util;


import java.io.IOException;

import java.io.InputStream;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.Properties;


public class DBUtils {

private static String driverName;

    private static String url;

    private static String user;

    private static String pwd;

    

    static {

    

    Properties prop = new Properties();

    

    InputStream is = DBUtils.class.getClassLoader()

    .getResourceAsStream("db.properties");

    

    try {

prop.load(is);


driverName = prop.getProperty("dn");


url = prop.getProperty("url");

user = prop.getProperty("un");

pwd = prop.getProperty("up");

} catch (IOException e) {


e.printStackTrace();

}

    }

    

  

    public static Connection getConn(){

    Connection conn = null;

    try {

Class.forName(driverName);

conn = DriverManager.getConnection(url,user,pwd);

} catch (Exception e) {


e.printStackTrace();

}   

    return conn;

    }

    

    public static void close(ResultSet rs,

    PreparedStatement pstm

    ,Connection conn){

        try {

        if(rs != null) {

            rs.close();

            }

            if(pstm != null) {

            pstm.close();

            }

            if(conn != null) {

            conn.close();

            }

        } catch(Exception e) {

        e.printStackTrace();

        }

    }

}



dn=com.mysql.jdbc.Driver

url=jdbc:mysql://localhost:3306/firstjsp?useUnicode=true&characterEncoding=UTF-8

un=root

up=root

<%@page import="com.SSHC.bean.Utype"%>

<%@page import="java.util.List"%>

<%@page import="com.SSHC.DAO.UtypeDao"%>

<%@ page language="java" contentType

="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%

//用selectAll()方法查询eduinfo表中的所有的数据:

    UtypeDao UtypeDao= new UtypeDao();

    List<Utype> list = UtypeDao.selectAll();

    //跳转到study.jsp页面,显示出学历下拉框

   /***用StringBuilder拼接html字符串,把内容

   用append放进html中,

   之后可以跳转时用EL表达式   ${html }直接调用:*/

    StringBuilder html = new StringBuilder();

    for(Utype U : list) {

    html.append("<option value='" 

            + U.getId() + "'>" + U.getTname() 

            + "</option>");

    } //有时用System.out.println(html)等来测试,找BUG等;

    request.setAttribute("html", html);

    request.getRequestDispatcher("forwardUtype.jsp")

        .forward(request, response);

%>


<%@ page language="java" contentType="text/html; 

charset=UTF-8" pageEncoding="UTF-8"%>

<%

    String path = request.getContextPath();

    String basePath = request.getScheme()

    +"://"+request.getServerName()

    +":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML

 4.01 Transitional//EN">

<html>

    <head>

        <base hreff="<%=basePath%>">

        <title></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">

    </head>

    <body>

        <select>

            <option>请选择</option>

            ${html }

        </select>

    </body>

</html>





运行结果截图:


info:信息




2、创建一个食品信息表foodinfo,包含id,name和price字段,插入一些数据,通过jdbc编程将foodinfo表中的所有数据拼接成一个表格显示在jsp页面上。

要求使用bean,dao和DbUtils

create table foodinfo(

id int primary key auto_increment,



name varchar(100) ,


price   double

);




insert into  foodinfo(name,price) values ('诗书画唱苹果',66.6),('诗书画唱香蕉',88.8 ),('诗书画唱葡萄',23.3 ),('诗书画唱桃子' ,13.14);


select * from foodinfo



package com.SSHC.bean;


public class foodinfo {

    private Integer id;

    private String name;

    private Double price;

public Integer getId() {

return id;

}

public void setId(Integer id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public Double getPrice() {

return price;

}

public void setPrice(Double price) {

this.price = price;

}


}



package com.SSHC.DAO;


import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;

import java.util.List;


import com.SSHC.Utils.DBUtils;

import com.SSHC.bean.foodinfo;



public class DAO {

    

public List<foodinfo>selectAll(){

String sql = "select * from foodinfo";

Connection conn = null;

PreparedStatement pstm = null;

ResultSet rs = null;

List<foodinfo> list = new ArrayList<foodinfo>();

try {

conn = DBUtils.getConn();

pstm = conn.prepareStatement(sql);

rs = pstm.executeQuery();

while(rs.next()) {

Integer id = rs.getInt("id");

String ename = rs.getString("name");

Double price = rs.getDouble("price");

//进行打包

foodinfo edu = new foodinfo();

edu.setId(id);

edu.setName(ename);

edu.setPrice(price);

//继续打包

list.add(edu);

}

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return list;

}

public static void main(String[] args) {

DAO ed = new DAO();

List<foodinfo>list = ed.selectAll();

System.out.println(list.size());

}

}



package com.SSHC.Utils;


import java.io.IOException;

import java.io.InputStream;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.Properties;




public class DBUtils {

private static String driverName;

    private static String url;

    private static String user;

    private static String pwd;

    

    static {

    //读取properties文件

    Properties prop = new Properties();

    //将db.properties文件读取到内存中去

    InputStream is = DBUtils.class.getClassLoader()

    .getResourceAsStream("db.properties");

    //加载内容

    try {

prop.load(is);

//读取内容

driverName = prop.getProperty("dn");

//System.out.println(driverName);

url = prop.getProperty("url");

user = prop.getProperty("un");

pwd = prop.getProperty("up");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

    }

    

    //获取数据库连接对象的方法

    public static Connection getConn(){

    Connection conn = null;

    try {

Class.forName(driverName);

conn = DriverManager.getConnection(url,user,pwd);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}   

    return conn;

    }

    

    public static void close(ResultSet rs,PreparedStatement pstm

    ,Connection conn){

        try {

        if(rs != null) {

            rs.close();

            }

            if(pstm != null) {

            pstm.close();

            }

            if(conn != null) {

            conn.close();

            }

        } catch(Exception e) {

        e.printStackTrace();

        }

    }

}


dn=com.mysql.jdbc.Driver

url=jdbc:mysql://localhost:3306/firstjsp?useUnicode=true&characterEncoding=UTF-8

un=root

up=root

<%@page import="com.SSHC.bean.foodinfo"%>


<%@page import="java.util.List"%>


<%@page import="com.SSHC.DAO.DAO"%>


<%@ page language="java" contentType


="text/html; charset=UTF-8" pageEncoding="UTF-8"%>


<%


    DAO DAO= new DAO();


    List<foodinfo> list = DAO.selectAll();



    StringBuilder html = new StringBuilder();


    for(foodinfo U : list) {

  

    html.append("<tr><td>" 


            + U.getId() + "</td><td>" + U.getName() 


            + "</td><td>"+ U.getPrice() +"</td></tr>");


    } 

    request.setAttribute("html", html);


    request.getRequestDispatcher("two.jsp")


        .forward(request, response);


%>



<%@ page language="java" contentType="text/html; 


charset=UTF-8" pageEncoding="UTF-8"%>


<%


    String path = request.getContextPath();


    String basePath = request.getScheme()


    +"://"+request.getServerName()


    +":"+request.getServerPort()+path+"/";


%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML


 4.01 Transitional//EN">


<html>


    <head>


        <base hreff="<%=basePath%>">


        <title></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">


    </head>


    <body>


      


          <form action="two.jsp" method="post">

         <table border="1">

         

         <tr><td>编号</td><td>名称</td><td>价格</td></tr>

        ${html }

         </table>

       

     </form>



           


    


    </body>


</html>




——————————


手动建Java web项目的方法:

不要点finsh,先点两次Next







例子:

用form表单来传内容,用EL表达式和param.获取传过来的内容:





<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%

    String path = request.getContextPath();

    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

    <head>

        <base hreff="<%=basePath%>">

        <title></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">

    </head>

    <body>

        <form action="perform.jsp" method="post">

            <label>账号:</label>

            <input type="text" name="act" />

            <br>

            <input type="radio" name="sex" value="男">男

            <input type="radio" name="sex" value="女">女

            <br>

            <input type="submit" value="提交" />

        </form>

    </body>

</html>



<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%

    String path = request.getContextPath();

    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

    request.setCharacterEncoding("utf-8");

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

    <head>

        <base hreff="<%=basePath%>">

        <title></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">

    </head>

    <body>

        <!-- 如果是通过表单方式提交的值,

                          在EL表达式中就必须通过param对象点出来 -->

        <!-- request.getParameter("act"); -->

        <h1>你输入的账号是:${param.act }</h1>

        <h1>选择的性别是:${param.sex }</h1>

    </body>

</html>





用上EL表达式的范围变量的知识,声明一个变量的作用域范围为session,在网页,分别用

${requestScope.msg }和 session:${sessionScope.msg }获取值,其中肯定只要session:${sessionScope.msg }能打印出内容,${requestScope.msg }在这里不能打印出内容:


<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%

    String path = request.getContextPath();

    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

    String msg = "Hello world";

    //只从request作用域去找有没有msg

    session.setAttribute("msg", msg);

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

    <head>

        <base hreff="<%=basePath%>">

        <title></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">

    </head>

    <body>

        <!-- 诗书画唱个人的理解:用上requestScope就是

        EL表达式仅从request作用域中去找有没有msg变量

        ,如果msg变量的作用域为request,哪么这里就会打印

        request,反之不会。这里上面的代码声明

        为 String msg = "Hello world";

        session.setAttribute("msg", msg);所以

        不会打印出"Hello world";

         -->

        request:${requestScope.msg }

        <br>

        <!-- 

        诗书画唱个人的理解:用上sessionScope就是

        EL表达式仅从session作用域中去找有没有msg变量,

        这里msg的作用域范围声明为了session,那么

        就会用${sessionScope.msg }在网页打印 

        出"Hello world"这个msg变量的被赋予的值-->

        session:${sessionScope.msg }

    </body>

</html>



读取数据库中的表中的数据,将这些数据组装成一个下拉框。

1、创建表eduinfo

2、在java代码中创建一个这个表对应的javabean,它的名字跟你的表名是一样的Eduinfo

3、根据eduinfo表中的列来创建Eduinfo类的属性,你的表中有几个列javabean中就有一个属性,而且属性名要跟表的列名一致。

4、创建表对应的数据访问类(dao),EduinfoDao

连接名一开始是随意的:





create table eduinfo(

id int primary key auto_increment,



ename varchar(100) 



);


--drop table  eduinfo

 --【个人的总结:当有一个列名设置为主键自增的时候就是在insert语句中注明列名,比如"(ename) ",

--不然会报错.如果不指名列名,

--就会默认插入"博士"到id列,但是数据类型不一样,同时id是主键自增的,不可以插入内容】

insert into eduinfo(ename) values ("博士"),('硕士' ),('本科' ),('大专' ),('高中' ),('初中' );

select * from eduinfo



package com.jy.bean;


public class Eduinfo {

    private Integer id;

    private String ename;

public Integer getId() {

return id;

}

public void setId(Integer id) {

this.id = id;

}

public String getEname() {

return ename;

}

public void setEname(String ename) {

this.ename = ename;

}

}



package com.jy.dao;


import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;

import java.util.List;


import com.jy.bean.Eduinfo;

import com.jy.util.Dbutil;


//就是实现增删改查的一个类

public class EduinfoDao {

    //用XXXDao(XXX为表名比如Eduinfo),Eduinfo:教育信息

//可查询eduinfo表中的所有的数据

//List用上泛型:

public List<Eduinfo>selectAll(){

String sql = "select * from eduinfo";

Connection conn = null;

PreparedStatement pstm = null;

ResultSet rs = null;

List<Eduinfo>list = new ArrayList<Eduinfo>();

try {

// 下面用上DBUtils(当然命名为Dbutil,也可以

// 自己知道是数据库常用工具就可以了:

conn = Dbutil.getConn();

pstm = conn.prepareStatement(sql);

rs = pstm.executeQuery();

while(rs.next()) {

Integer id = rs.getInt("id");

String ename = rs.getString("ename");

//进行打包:

Eduinfo edu = new Eduinfo();

edu.setId(id);

edu.setEname(ename);

//继续打包:

list.add(edu);

}

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return list;

}

public static void main(String[] args) {

EduinfoDao ed = new EduinfoDao();

List<Eduinfo>list = ed.selectAll();

System.out.println(list.size());

}

}


package com.jy.util;


import java.io.IOException;

import java.io.InputStream;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.Properties;


public class Dbutil {

private static String driverName;

    private static String url;

    private static String user;

    private static String pwd;

    

    static {

    //读取properties文件

    Properties prop = new Properties();

    //将db.properties文件读取到内存中去

    InputStream is = Dbutil.class.getClassLoader()

    .getResourceAsStream("db.properties");

    //加载内容

    try {

prop.load(is);

//读取内容

driverName = prop.getProperty("dn");

//System.out.println(driverName);

url = prop.getProperty("url");

user = prop.getProperty("un");

pwd = prop.getProperty("up");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

    }

    

    //获取数据库连接对象的方法

    public static Connection getConn(){

    Connection conn = null;

    try {

Class.forName(driverName);

conn = DriverManager.getConnection(url,user,pwd);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}   

    return conn;

    }

    

    public static void close(ResultSet rs,PreparedStatement pstm

    ,Connection conn){

        try {

        if(rs != null) {

            rs.close();

            }

            if(pstm != null) {

            pstm.close();

            }

            if(conn != null) {

            conn.close();

            }

        } catch(Exception e) {

        e.printStackTrace();

        }

    }

}



dn=com.mysql.jdbc.Driver

url=jdbc:mysql://localhost:3306/firstjsp?useUnicode=true&characterEncoding=UTF-8

un=root

up=root




<%@page import="com.jy.bean.Eduinfo"%>

<%@page import="java.util.List"%>

<%@page import="com.jy.dao.EduinfoDao"%>

<%@ page language="java" contentType

="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%

    //用selectAll()方法查询eduinfo表中的所有的数据:

    EduinfoDao eduinfoDao = new EduinfoDao();

    List<Eduinfo>list = eduinfoDao.selectAll();

    //跳转到study.jsp页面,显示出学历下拉框

   /***用StringBuilder拼接html字符串,把内容

   用append放进html中,

   之后可以跳转时用EL表达式   ${html }直接调用:*/

    StringBuilder html = new StringBuilder();

    for(Eduinfo edu : list) {

    html.append("<option value='" 

            + edu.getId() + "'>" + edu.getEname() 

            + "</option>");

    }

    //有时用System.out.println(html)等来测试,找BUG等;

    request.setAttribute("html", html);

    request.getRequestDispatcher("study.jsp")

        .forward(request, response);

%>


<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%

    String path = request.getContextPath();

    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

    <head>

        <base hreff="<%=basePath%>">

        <title></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">

    </head>

    <body>

        <select>

            <option>请选择</option>

            ${html }

        </select>

    </body>

</html>



运行:

个人备注的注意事项:


_____________________



下面是JSP的知识的集合:

一、页面跳转方式

二、传参方式


在页面中需要输入日期框的时候,我们不能够直接写三个文本输入框,可以使用脚本文件(从网上面下载)来引入一个日期框(JS文件)

在eclipse项目中使用日期框:

1、将日期脚本文件拷贝到工程WebContent目录下(可以创建子文件夹)

2、创建jsp页面,在页面中引入日期脚本文件

"3、在页面中编写如下的代码:

<input type=""text"" readonly 

            onclick=""new Calendar().show(this);"" />"


页面跳转的方式有两种:

1、转发

2、重定向

"区别:

1、浏览器地址栏显示的最后的地址不同,转发就显示前面的请求的地址,而重定向会显示最后跳转的页面的地址

2、转发就是一次请求,重定向是两次请求"

3、重定向可以跳转到项目外面的页面去

项目中一般建议使用转发方式跳转


JS代码中优先使用单引号


传参方式:

"1、浏览器地址栏中直接传入

http://localhost:8888/j190802/demo.jsp?act=admin&pwd=123&sex=男"

2、表单提交


一、getParameter和getAttribute的区别。

二、四大作用域:pageContext,request,session,application

三、EL表达式


getAttribute和setAttribute方法

getParameter和getAttribute的区别:

1、getParameter返回值是String,getAttribute返回值是Object

2、getParameter方法是一个单身狗,没有对应的setParameter方法

如果调用setAttribute方法,后面的程序中就必定会调用getAttribute方法

3、getParameter的使用场景:表单提交时获取数据,url路径中夹带的参数

getAttribute的使用场景:页面转发时调用。


pageContext,session和application跟request和response一样,可以直接拿过来使用

"pageContext,request,session以及application叫jsp页面的四大作用域,指的就是你放在这些对象中的变量在哪个范围内有效。

四大作用域对象都有setAttribute方法和getAttribute方法。"

pageContext:表示放在这个对象中(调用setAttribute方法)的变量在本JSP页面有效

request:表示放在同一次请求中的变量有效

session:表示同一次会话中的变量有效

application:只要不重启服务器,放在里面的变量就会一直有效


request:当进行页面转发时传递参数

session:当实现购物车功能时就需要使用session


购物车:需要访问很多的页面和发送很多的搜索请求,购物车中的数据必须要一直有效。


一、作业讲解

二、EL表达式


EL表达式就是JSP中的一种特有的语言,可以简化我们的java代码。

EL表达式写法:${表达式},注意:{}中间只能是表达式,不能是语句

EL表达式有两种运算符:.和[](JS对象的运算符)

EL表达式可以写在JSP页面的任何地方


"EL表达式中的变量的显示过程:会依次从pageContext,request,session以及

applicaion四个作用域中找这个变量,一旦找到了就返回这个值,如果四个作用域都找不到,就显示为""""(不是显示为null)"


一、EL表达式显示map和list中的值。

二、通过EL表达式加载表单数据,修改数据时使用


${}中比较两个字符串是否相等,可以使用==也可以使用eq

${message == "success" ? "登录成功" : "登录失败"}

${message eq "success" ? "登录成功" : "登录失败"}


复习三大容器:List,Map,Set

List,Map和Set都是接口,所以不能够直接new出来的

List最常用的实现类:ArrayList

Map最常用的实现类:HashMap

Set最常用的实现类:HashSet


一、EL表达式中的范围变量

二、表单提交后的EL表达式

三、EL表达式

如果是通过表单方式提交的数据,那么通过EL表达式获取就必须使用param隐式对象

EL表达式中的范围变量:

pageContext:pageScope

request:requestScope

session:sessionScope

application:applicationScope

上面四个scope变量都是用来替换getAttribute方法的

而param隐式对象就是用来替换getParameter方法的


手动建Java web项目的方法,JSP,DBUtils,MySQL,下拉框,form表单显示【诗书画唱】的评论 (共 条)

分享到微博请遵守国家法律