根据上篇文章的HttpServer进行修改。
- 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()));
- }
- }
- 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 ServletException, IOException {
- resp.setCharacterEncoding(