区块链(10):java区块链项目的Web服务整体实现

根据上篇文章的HttpServer进行修改。

1 区块链的查询服务的web实现

    public class BlocksServlet extends HttpServlet {
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            resp.setCharacterEncoding("UTF-8");
            resp.getWriter().println(JSON.toJSONString(blockService.getBlockChain()));
        }
    }

2 区块链挖矿的服务web实现

    public class MineBlockServlet extends HttpServlet {

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            this.doPost(req, resp);
        }

        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletExceptio

你可能感兴趣的:(区块链,区块链,java,前端)