Javaweb基礎(chǔ)(六)JavaBean-EL-JSTL-MVC-WebCRUD

JavaBean規(guī)范

1.JavaBean:

JavaBean 是一種JAVA語言寫成的可重用組件(類)。(JavaBean就是特殊的類)

1):設(shè)計JavaBean必須遵循的規(guī)范:
  • 1):把JavaBean類設(shè)計為public的.
  • 2):必須具有公共的無參數(shù)構(gòu)造器,(方便反射創(chuàng)建對象).
  • 3):一般的,JavaBean的字段是私有的,外界不能訪問,我們得提供讓外界訪問字段的公共方法.
    (getter/setter:必須遵循一定的規(guī)則)--->屬性.
2):JavaBean的分類:
  • 1):有用戶界面(UI,User Interface)的JavaBean(Panel,Window,Button等);
  • 2):沒有用戶界面,主要負(fù)責(zé)處理事務(wù)(如數(shù)據(jù)運(yùn)算,操縱數(shù)據(jù)庫)的JavaBean。
    比如:dao組件,domain,service等等.
3):JavaBean具有的成員:
  • 1):事件(event),存在于有界面的JavaBean中.(點(diǎn)擊事件).
  • 2):方法(method):
  • 3):屬性(property):
    屬性(attribute/property):
    attribute:一般來說,在Java語言中沒有這一個概念,如果有就只能是注解中的抽象方法,很多人習(xí)慣把字段稱之為屬性.
    property:是JavaBean中專門向外界暴露獲取/設(shè)置值的成員,有g(shù)etter/setter方法所決定.
4).獲取字段的值(readMethod)/getter方法:
      public   數(shù)據(jù)類型    getXyz(){
             return 字段變量;
      }

如果: getUsername: 屬性: username
如果: getUserName: 屬性: userName
如果: getISBN: 順序: ISBN
注意: 方法必須是public,必須有返回類型,必須無參數(shù). 如果字段是boolean類型,則沒有g(shù)etter方法,而是is方法.

5).給字段設(shè)置值(WriteMethod)/setter方法:
     public  void  setXyz(數(shù)據(jù)類型 變量){
          this.字段 = 變量;
     }

注意:方法是public的,必須無返回類型,必須有參數(shù).

一般的,我們都是先寫字段,然后再通過Eclipse工具自動生成getter/setter方法.
此時:屬性名和字段名相同.
有屬性,不一定有字段.

private String firstName;
private String lastName;

public String getFullName(){//屬性: fullName
    return firstName + "." + lastName;
}
6).JavaBean什么時候提供getter/setter:
  • 如果外界需要獲取JavaBean中的數(shù)據(jù): 則提供getter.
  • 如果外界需要給JavaBean設(shè)置值: 則提供setter.

2.Lombok — Java代碼自動生成 開發(fā)利器

3.Introspector:內(nèi)省機(jī)制核心類

反射機(jī)制: 獲取字節(jié)碼對象,創(chuàng)建該字節(jié)碼對應(yīng)類的對象以及調(diào)用方法.
內(nèi)省機(jī)制: 操作avaBean中的成員(事件,方法,屬性):獲取屬性/設(shè)值屬性.

Introspector:內(nèi)省機(jī)制核心類:

內(nèi)省機(jī)制核心類.png

4.JavaBean和Map的轉(zhuǎn)換操作

JavaBean包含屬性(屬性名=屬性值).
屬性名1 = 屬性值1
屬性名2 = 屬性值2
屬性名3 = 屬性值3
這一種結(jié)構(gòu)就非常類似于Map結(jié)構(gòu).
key1=value1
key2=value2
key3=value3

所以我們把Map結(jié)構(gòu)的數(shù)據(jù)也當(dāng)做是JavaBean來使用.
把Map的key作為屬性名稱,把Map的value作為屬性值.

JavaBean和Map的轉(zhuǎn)換操作:

JavaBean和Map的轉(zhuǎn)換操作.png

Apache組織提供了專門操作JavaBean的工具.
BeanUtils組件.
看資料

EL(表達(dá)語言)

http://blog.csdn.net/qq_26676207/article/details/52385113
作用域?qū)ο?getAttribute(String name):表示從當(dāng)前作用域中去尋找指定屬性名稱的屬性值.
找到就顯示,找不到顯示null.
pageContext.findAttribute(String name):依次從page,request,session,application的作用域中尋找指定屬性的屬性值.
如果有屬性就顯示屬性值,沒有屬性就顯示空字符(照顧用戶).
<%=pageContext.findAttribute("msg")!=null ? pageContext.findAttribute("msg") : ""%>

1.EL:表達(dá)式語言

目的:從作用域中取出共享數(shù)據(jù).
語法:${屬性名稱}. 如果有該屬性就顯示屬性值,沒有該屬性輸出空字符串.
${msg}等價于:
<%=pageContext.findAttribute("msg")!=null ? pageContext.findAttribute("msg") : ""%>

如果作用域中的屬性名相同,想通過EL獲取出不同作用域中的屬性.
此時得使用到EL的內(nèi)置對象.${內(nèi)置對象}.
屬性范圍在EL中的名稱

作用域 方法 意義
page ${pageScope.msg} 僅僅只從page作用域?qū)ふ襪sg屬性.
request ${requestScope.msg} 僅僅只從request作用域?qū)ふ襪sg屬性.
session ${sessionScope.msg}
application ${applicationScope.msg}
暴露getter方法.png

2.在EL中訪問JavaBean.

步驟:
1):把JavaBean對象存儲到作用域中.
2):通過EL來訪問JavaBean.

Person person = new Person();
req.setAttribute("p", person);

訪問規(guī)則:
方式1:${p.屬性名稱}----->等價于${p.getXxx()},此時要保證屬性必須有g(shù)etter方法.(推薦的)
方式2:${p["屬性名稱"]}:處理特殊的屬性名或Map的key.

${p}:得到作用域中屬性名為p的Person對象.
${p.name}:d得到Person對象的name屬性的值. 要求Person類中必須有name的getter方法.

3.EL的細(xì)節(jié):

1):使用EL來獲取當(dāng)前應(yīng)用的上下文路徑:
${pageContext.getRequest().getContextPath()}:
等價于:${pageContext.request.contextPath}

2):從Tomcat7開始,支持在EL中直接調(diào)用方法,Tomcat6里面不支持,建有依然使用屬性調(diào)用.
${pageContext.getRequest().getContextPath()}:

3):判斷集合是否為空:
情況1: 集合對象引用為空.
情況2: 集合對象有引用,但是沒有元素.

對于集合來說:
${empty list}:表示判斷l(xiāng)ist既不能等于null,并且有元素,才會返回false.

JSTL(Java標(biāo)準(zhǔn)標(biāo)簽庫)

消除jsp中java代碼.png

要消除JSP中的Java代碼,咱們就得使用Java的標(biāo)簽庫,每一個標(biāo)簽的背后其實(shí)就是一段Java代碼.
標(biāo)簽由SUN公司制定規(guī)范,再由用戶自己定義開發(fā)的出來.------>自定義標(biāo)簽.

一般的,我們不用自定義標(biāo)簽,我們使用JSTL(Java的標(biāo)準(zhǔn)標(biāo)簽庫(SUN自己提供的標(biāo)簽庫)).

1.使用JSTL的準(zhǔn)備環(huán)境:

1):需要拷貝相應(yīng)的jar.
jstl.jar
standard.jar
el-api.jar
jsp-api.jar

JSTL的jar包.png

2):需要在使用JSTL的JSP頁面引用標(biāo)簽庫.

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

3):使用JSTL的標(biāo)簽庫了.

JSTL標(biāo)簽庫使用方法.png

2.JSTL的常用標(biāo)簽庫:

自動提示.png

1):判斷語句標(biāo)簽: if,if-else,if-elseif-else.

循環(huán)語句標(biāo)簽.png

2):循環(huán)迭代標(biāo)簽:for-each.

for-each.png

3):其他標(biāo)簽.
日期格式化標(biāo)簽.

日期格式化標(biāo)簽.png

JDBC+Servlet+JSP綜合

1.操作流程:

1):新建一個Web項目.
2):拷貝之前已經(jīng)編寫好的domain,dao,util,配置文件,jar包.
3):測試DAO,保證后臺測試通順,再做前臺.
拷貝web的依賴包(5).
4):做前臺,編寫Servlet/JSP.

2.Servlet的職責(zé):

1:接受請求參數(shù),封裝成對象
2:調(diào)用業(yè)務(wù)方法處理請求
3:控制界面跳轉(zhuǎn)

crud.png

MVC思想

JavaEE開發(fā)模式:先后經(jīng)歷了Model1,Model2,MVC.

1.模式1(Model1):

以JSP為中心的動態(tài)網(wǎng)頁開發(fā)模式.
使用技術(shù): JSP + JavaBean.

優(yōu)點(diǎn):開發(fā)很快.
缺點(diǎn):職責(zé)不分明,在JSP中大量存在Java代碼.
解決方案:Model2.
職責(zé)分明:各自做各自最擅長的事情.

Moudle1.png

2.模式2(Model2):

在Model1中,咱們的JSP既要做頁面輸出,還要做處理請求的操作.
在這里,JSP是不擅長最請求處理的,擅長最界面輸出.
我們就把JSP中處理請求的代碼提取到了Servlet.

以Servlet為中心的動態(tài)網(wǎng)頁開發(fā)模式.
使用技術(shù):JSP + Servlet + JavaBean.

優(yōu)勢:體現(xiàn)出了責(zé)任分離的思想.維護(hù)性比較高.

Moudle2.png

3.MVC

MVC其實(shí)和Model2很相似.
MVC最大的亮點(diǎn)就是體現(xiàn)責(zé)任分離.
M:Model:數(shù)據(jù)模型對象.(封裝數(shù)據(jù)/處理業(yè)務(wù)邏輯):JavaBean
V:View: 展現(xiàn)界面,顯示數(shù)據(jù).(JSP/html/js/flash)
C:Controller:控制器(接受所有的請求和界面的跳轉(zhuǎn)):Servlet
MVC框架:Struts2/SpringMVC

MVC.png

JavaBean:數(shù)據(jù)模型對象.(封裝數(shù)據(jù)/處理業(yè)務(wù)邏輯)
Servlet:
1):接受請求參數(shù),封裝成對象.
2):調(diào)用業(yè)務(wù)方法處理請求.
3):控制界面跳轉(zhuǎn).
JSP: 展現(xiàn)頁面,顯示數(shù)據(jù).

MVC最早的時候使用運(yùn)用到CS領(lǐng)域的.
BS領(lǐng)域,必須先有請求而后才有響應(yīng)操作.

MVC.png

合并Servlet

合并Servlet.png

WebCRUD

項目結(jié)構(gòu).png

1.Domain

public class Product {
    private long id;
    private String productName;   //產(chǎn)品名稱
    private String brand;   //產(chǎn)品標(biāo)簽
    private String supplier;   //產(chǎn)品父類型
    private double costPrice;  //成本價格
    private double salePrice;  //售價
    private double cutoff;   //折扣
    private long dir_id;  //目錄id
    
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    public String getProductName() {
        return productName;
    }
    public void setProductName(String productName) {
        this.productName = productName;
    }
    public String getBrand() {
        return brand;
    }
    public void setBrand(String brand) {
        this.brand = brand;
    }
    public String getSupplier() {
        return supplier;
    }
    public void setSupplier(String supplier) {
        this.supplier = supplier;
    }
    public double getCostPrice() {
        return costPrice;
    }
    public void setCostPrice(double costPrice) {
        this.costPrice = costPrice;
    }
    public double getSalePrice() {
        return salePrice;
    }
    public void setSalePrice(double salePrice) {
        this.salePrice = salePrice;
    }
    public double getCutoff() {
        return cutoff;
    }
    public void setCutoff(double cutoff) {
        this.cutoff = cutoff;
    }
    public long getDir_id() {
        return dir_id;
    }
    public void setDir_id(long dir_id) {
        this.dir_id = dir_id;
    }
    
    
    @Override
    public String toString() {
        return "Product [id=" + id + ", productName=" + productName + ", brand=" + brand + ", supplier=" + supplier
                + ", costPrice=" + costPrice + ", salePrice=" + salePrice + ", cutoff=" + cutoff + ", dir_id=" + dir_id
                + "]";
    }
}

2.DAO

public interface IProductDAO {
    
    
    
    /**
     * 保存
     * @param pro
     */
    public void save(Product pro);
    
    /**
     * 更新
     * @param pro
     */
    public void update(Product pro);
    
    /**
     * 刪除
     * @param id
     */
    public void delete(Long id);
    
    
    /**
     * 查詢單個
     * @param id
     * @return
     */
    public Product getSimple(Long id);
    
    
    /**
     * 查詢?nèi)?     * @return
     */
    public List<Product> list();

}

3.DAOImpl

public class ProductDAOImpl implements IProductDAO{

    @Override
    public void save(Product pro) {
        String sql = "INSERT INTO t_product ("
                + "productName,"
                + "brand,"
                + "supplier,"
                + "costPrice,"
                + "salePrice,"
                + "cutoff,"
                + "dir_id) VALUES (?,?,?,?,?,?,?);";
        Object[] params = {
                pro.getProductName(), 
                pro.getBrand(), 
                pro.getSupplier(), 
                pro.getCostPrice(),
                pro.getSalePrice(), 
                pro.getCutoff(), 
                pro.getDir_id() };
        JdbcTemplate.update(sql, params);
        
    }

    @Override
    public void update(Product pro) {
        String sql = "UPDATE t_product SET "
                + "productName = ?,"
                + "brand = ?,"
                + "supplier = ?,"
                + "costPrice= ?, "
                + "salePrice= ?, "
                + "cutoff= ?, "
                + "dir_id= ? "
                + "WHERE id =?";
        Object[] params = { pro.getProductName(), pro.getBrand(), pro.getSupplier(), pro.getCostPrice(),
                pro.getSalePrice(), pro.getCutoff(), pro.getDir_id(), pro.getId() };
        JdbcTemplate.update(sql, params);
        
    }

    @Override
    public void delete(Long id) {
        String sql = "DELETE FROM t_product WHERE id = ?";
        JdbcTemplate.update(sql, id);
        
    }

    @Override
    public Product getSimple(Long id) {
        String sql = "SELECT * FROM t_product WHERE id = ?";
        List<Product> list = JdbcTemplate.query(sql, new ProductResultSetHandler(),id);
        Product result=list.size() == 1 ? list.get(0) : null;
        if(result!=null){
            System.out.println("result:"+result.toString());
        }
        return result;
    }

    @Override
    public List<Product> list() {
        String sql = "SELECT * FROM t_product";
        List<Product> list = JdbcTemplate.query(sql, new ProductResultSetHandler());
        for (Iterator iterator = list.iterator(); iterator.hasNext();) {
            Product product = (Product) iterator.next();
            System.out.println("product:" + product.toString());
        }
        return list;
    }

}

4.JdbcUtil

public class JdbcUtil {

    private static Properties properties = new Properties();
    static {
        // 在JdbcUtil的字節(jié)碼被加載進(jìn)JVM就執(zhí)行,只是執(zhí)行一次
        try {
            InputStream inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("db.properties");
            properties.load(inStream);
            Class.forName(properties.getProperty("driverClassName"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    
    /**
     * 獲取連接
     * @return
     */
    public static Connection getConn() {
        Connection conn = null;
        try {
            // 加載驅(qū)動
            conn = DriverManager.getConnection(properties.getProperty("url"), properties.getProperty("userName"),
                    properties.getProperty("password"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }

    /**
     * 關(guān)閉資源
     * 
     * @param conn
     * @param st
     * @param rs
     */
    public static void close(Connection conn, Statement st, ResultSet rs) {
        try {
            if (rs != null) {
                rs.close();
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        } finally {
            try {
                if (st != null) {
                    st.close();
                }
            } catch (Exception e3) {
                e3.printStackTrace();
            } finally {
                try {
                    if (conn != null) {
                        conn.close();
                    }
                } catch (Exception e3) {
                    e3.printStackTrace();
                }
            }
        }
    }
}

5.db.properties

driverClassName = com.mysql.jdbc.Driver
url=jdbc:mysql:///product
userName=root
password=123456

6.JdbcTemplate

public class JdbcTemplate {
    
    
    /**
     * DML
     * @param sql
     * @param params
     * @return
     */
    public static int update(String sql, Object... params) {
        Connection conn = null;
        PreparedStatement ps = null;
        try {
            conn = JdbcUtil.getConn();
            ps = conn.prepareStatement(sql);
            System.out.println("sql:"+sql);
            // 設(shè)置占位參數(shù)
            for (int i = 0; i < params.length; i++) {
                ps.setObject(i+1, params[i]);
            }
            return ps.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            JdbcUtil.close(conn, ps, null);
        }
        return 0;
    }

    
    /**
     * DQL
     * @param sql
     * @param handler
     * @param params
     * @return
     */
    public static <T> T query(String sql, IResultSetHandler<T> handler, Object... params) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            conn = JdbcUtil.getConn();
            ps = conn.prepareStatement(sql);
            // 設(shè)置占位參數(shù)
            for (int i = 0; i < params.length; i++) {
                ps.setObject(i+1, params[i]);
            }
            rs = ps.executeQuery();
            return handler.handle(rs);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            JdbcUtil.close(conn, ps, null);
        }
        return null;
    }

}

7.IResultSetHandler

public interface IResultSetHandler<T> {
    
    T handle(ResultSet rs) throws SQLException;
}

8.ProductResultSetHandler

public class ProductResultSetHandler implements IResultSetHandler<List<Product>>{

    @Override
    public List<Product> handle(ResultSet rs) throws SQLException {
        List<Product> list=new ArrayList<Product>();
        while(rs.next()){
            Product pro = new Product();
            pro.setId(rs.getLong("id"));
            pro.setProductName(rs.getString("productName"));
            pro.setBrand(rs.getString("brand"));
            pro.setSupplier(rs.getString("supplier"));
            pro.setCostPrice(rs.getDouble("costPrice"));
            pro.setSalePrice(rs.getDouble("salePrice"));
            pro.setCutoff(rs.getDouble("cutoff"));
            pro.setDir_id(rs.getLong("dir_id"));
            list.add(pro);
        }
        return list;
    }

}

9.ProductServlet

@WebServlet("/product")
public class ProductServlet extends HttpServlet {

    IProductDAO productDao;

    @Override
    public void init() throws ServletException {
        productDao = new ProductDAOImpl();
    }

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String cmd = request.getParameter("cmd");
        if ("delete".equals(cmd)) {
            this.delete(request, response);
        } else if ("edit".equals(cmd)) {
            this.edit(request, response);
        } else if ("save".equals(cmd)) {
            this.addOrUpdate(request, response);
        } else {
            this.list(request, response);
        }
    }
    
    
    
    /**
     * 獲取全部
     * 
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    protected void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Product> products = productDao.list();
        // 控制頁面跳轉(zhuǎn)
        request.setAttribute("products", products);
        request.getRequestDispatcher("/WEB-INF/views/list.jsp").forward(request, response);
    }
    
    
    
    /**
     * 增加或者修改
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    protected void addOrUpdate(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 1.接收參數(shù)
        Product pro = null;
        try {
            pro = requset2Obj(request,response);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("添加失敗");
            response.sendRedirect("/product/product");
            return;
        }
        if(pro.getId()>0){
            productDao.update(pro);
        }else{
            productDao.save(pro);
        }
        response.sendRedirect("/product/product");
    }
    
    
    
    /**
     * 編輯
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    protected void edit(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
        String id = request.getParameter("id");
        if(id!=null){
            try {
                long productId=Long.valueOf(id);
                Product product =productDao.getSimple(productId);
                //控制頁面跳轉(zhuǎn)
                request.setAttribute("product", product);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        request.getRequestDispatcher("WEB-INF/views/edit.jsp").forward(request, response);
    }

    
    
    /**
     * 刪除
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    protected void delete(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
        String id = request.getParameter("id");
        if(hasLength(id)){
            productDao.delete(Long.valueOf(id));
        }
        response.sendRedirect("/product/product");
    }
    
    
    
    protected void query(){
        
    }
    
    
    private Product requset2Obj(HttpServletRequest request, HttpServletResponse response) throws Exception{
        String productName = request.getParameter("productName");
        String brand = request.getParameter("brand");
        String supplier = request.getParameter("supplier");
        String costPrice = request.getParameter("costPrice");
        String salePrice = request.getParameter("salePrice");
        String cutoff = request.getParameter("cutoff");
        String dir_id = request.getParameter("dir_id");
        String id = request.getParameter("id");
        
        Product pro = new Product();
        pro.setProductName(productName);
        pro.setBrand(brand);
        pro.setSupplier(supplier);
        pro.setCostPrice(Double.valueOf(costPrice));
        pro.setSalePrice(Double.valueOf(salePrice));
        pro.setCutoff(Double.valueOf(cutoff));
        pro.setDir_id(Long.valueOf(dir_id));
        if(hasLength(id)){
            pro.setId(Long.valueOf(id));
        }
        System.out.println("增加:"+pro.toString());
        return pro;
    }
    
    
    private boolean hasLength(String str){
        return str!=null&&!"".equals(str.trim());
    }

}

10.list.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<a href="/product/product?cmd=edit">添加商品</a>
    <table cellpadding="0" cellspacing="0" border="1" width="800">
        <tr>
            <th>產(chǎn)品名稱</th>
            <th>產(chǎn)品標(biāo)簽</th>
            <th>產(chǎn)品父類型</th>
            <th>成本價格</th>
            <th>銷售價格</th>
            <th>折扣</th>
            <th>目錄id</th>
            <th>操作</th>
        </tr>
        <c:if test="${empty products}">

            <tr align="center">沒有數(shù)據(jù)</tr>
        </c:if>
        <c:forEach items="${products}" var="pro" varStatus="vs">
            <tr style='background:${vs.count%2==0?"gray":""}'>
                <td>${pro.productName}</td>
                <td>${pro.brand}</td>
                <td>${pro.supplier}</td>
                <td>${pro.costPrice}</td>
                <td>${pro.salePrice}</td>
                <td>${pro.cutoff}</td>
                <td>${pro.dir_id}</td>
                <td>
                    <a href="/product/product?cmd=delete&id=${pro.id}">刪除</a>
                    <a href="/product/product?cmd=edit&id=${pro.id}">編輯</a>
                </td>
            </tr>
        </c:forEach>
    </table>

</body>
</html>

11.edit.jsp

<%@ 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>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>編輯產(chǎn)品</title>
</head>
<body>
<form action="product?cmd=save" method="post">
        <input type="hidden" name="id" value="${product.id}"/>
        <table border="1" cellpadding="0" cellspacing="0">
            <tr>
                <td>產(chǎn)品名稱</td>
                <td><input type="text" name="productName" value="${product.productName}"/></td>
            </tr>
            <tr>
                <td>產(chǎn)品標(biāo)簽</td>
                <td><input type="text" name="brand" value="${product.brand}"/></td>
            </tr>
            <tr>
                <td>產(chǎn)品父類型</td>
                <td><input type="text" name="supplier" value="${product.supplier}"/></td>
            </tr>
            <tr>
                <td>售價</td>
                <td><input type="text" name="salePrice" value="${product.salePrice}"/></td>
            </tr>
            <tr>
                <td>成本價格</td>
                <td><input type="text" name="costPrice" value="${product.costPrice}"/></td>
            </tr>
            <tr>
                <td>折??扣</td>
                <td><input type="text" name="cutoff" value="${product.cutoff}"/></td>
            </tr>
            <tr>
                <td>目錄id</td>
                <td>
                    <select name="dir_id">
                        <option value="11">11</option>
                        <option value="22">22</option>
                        <option value="33">33</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" value="保存"/></td>
            </tr>
        </table>
    </form>
</body>
</html>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、什么是JavaBean (1)JavaBean是一個遵循特定寫法的java類,它通常具有如下特點(diǎn):這個java...
    yjaal閱讀 1,683評論 2 8
  • 這部分主要是與Java Web和Web Service相關(guān)的面試題。 96、闡述Servlet和CGI的區(qū)別? 答...
    雜貨鋪老板閱讀 1,501評論 0 10
  • 1. Java基礎(chǔ)部分 基礎(chǔ)部分的順序:基本語法,類相關(guān)的語法,內(nèi)部類的語法,繼承相關(guān)的語法,異常的語法,線程的語...
    子非魚_t_閱讀 34,637評論 18 399
  • 1.學(xué)習(xí)內(nèi)容 JSP技術(shù)入門和常用指令 JSP的內(nèi)置對象&標(biāo)簽介紹 EL表達(dá)式&EL的內(nèi)置對象 2.JSP技術(shù)入門...
    WendyVIV閱讀 2,324評論 1 18
  • 技術(shù)小白,求大神指教,如有重復(fù),純屬巧合。 /etc/issue文件是Linux系統(tǒng)開機(jī)啟動時在命令行界面彈出的歡...
    王王王小白閱讀 12,013評論 0 0

友情鏈接更多精彩內(nèi)容