package com.juick.www; import com.mitchellbosecke.pebble.error.PebbleException; import com.mitchellbosecke.pebble.template.PebbleTemplate; import org.springframework.jdbc.core.JdbcTemplate; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; /** * * @author ugnich */ public class Errors { public static void doGet404(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); response.setStatus(404); response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { PebbleTemplate template = Utils.getEngine().getTemplate("views/404.html"); Map context = new HashMap<>(); context.put("title", "404 Страница не найдена"); context.put("visitor", visitor); template.evaluate(out, context); } catch (PebbleException e) { // log("pebble exception", e); } } }