package com.demo; import com.utils.Utils; import org.springframework.web.servlet.HandlerInterceptor; import javax.servlet.http.*; public class Interceptor implements HandlerInterceptor { @Override public boolean preHandle( HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); request.setCharacterEncoding("utf-8"); if( Utils.getPeoperties("aliNotifyUrl").replace("null","").trim().length()<1 || Utils.getPeoperties("appid").replace("null","").trim().length()<1 || Utils.getPeoperties("private_key").replace("null","").trim().length()<1 || Utils.getPeoperties("public_key").replace("null","").trim().length()<1 || Utils.getPeoperties("pwd").replace("null","").trim().length()<1 || Utils.getPeoperties("dburl").replace("null","").trim().length()<1 || Utils.getPeoperties("dbport").replace("null","").trim().length()<1 || Utils.getPeoperties("dbname").replace("null","").trim().length()<1 || Utils.getPeoperties("dbusername").replace("null","").trim().length()<1 || Utils.getPeoperties("dbpassword").replace("null","").trim().length()<1 ){ response.sendRedirect("./install.html"); return false; }else return true; } }