架构探险——从零开始写Java Web框架》第二章照作

沉下来慢慢看实现了。

越来越觉得可以和DJANGO作对比。

package org.smart4j.chapter2.model;

/**
 * Created by sahara on 2016/3/14.
 */
public class Customer {
    private long id;
    private String name;
    private String contact;
    private String telephone;
    private String email;
    private String remark;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
package org.smart4j.chapter2.service;

import java.util.List;
import java.util.Map;
import org.smart4j.chapter2.model.Customer;
/**
 * Created by sahara on 2016/3/14.
 */
public class CustomerService {
    public List<Customer> getCustomerList(String keyword) {
        // TODO
        return null;
    }

    public Customer getCustomer(long id) {
        // TODO
        return null;
    }

    public boolean createCustomer(Map<String, Object> fieldMap) {
        // TODO
        return false;
    }

    public boolean updateCustomer(long id, Map<String, Object> fieldMap) {
        // TODO
        return false;
    }
}
package org.smart4j.chapter2.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by sahara on 2016/3/14.
 */
@WebServlet("/customer_create")
public class CustomerCreateServlet extends HttpServlet{

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException{
        req.getRequestDispatcher("/WEB-INF/view/customer_create.jsp").forward(req, resp);
        // TODO
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException{
        // TODO
    }
}

架构探险——从零开始写Java Web框架》第二章照作

架构探险——从零开始写Java Web框架》第二章照作

上一篇:《架构探险——从零开始写Java Web框架》这书不错,能看懂的入门书


下一篇:node.js module初步理解-(转载)