| | |
| | | package com.zy.common.web; |
| | | |
| | | import com.core.common.Cools; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | @Controller |
| | | public class RouterController { |
| | | |
| | | @Value("${spring.application.name}") |
| | | private String applicationName; |
| | | @Value("${server.servlet.context-path}") |
| | | private String contextPath; |
| | | |
| | | @RequestMapping("/") |
| | | public void index(HttpServletResponse response) { |
| | | try{ |
| | | String redirect = Cools.isEmpty(applicationName)?"views/login.html":"/"+applicationName+"/views/login.html"; |
| | | response.sendRedirect(redirect); |
| | | response.sendRedirect(contextPath+"/views/index.html"); |
| | | } catch (Exception ex){ |
| | | ex.printStackTrace(); |
| | | } |
| | |
| | | @RequestMapping("/login") |
| | | public void login(HttpServletResponse response) { |
| | | try{ |
| | | String redirect = Cools.isEmpty(applicationName)?"/views/login.html":"/"+applicationName+"/views/login.html"; |
| | | response.sendRedirect(redirect); |
| | | response.sendRedirect(contextPath+"/views/login.html"); |
| | | } catch (Exception ex){ |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping("/control") |
| | | public void control(HttpServletResponse response) { |
| | | try{ |
| | | response.sendRedirect(contextPath+"/views/control.html"); |
| | | } catch (Exception ex){ |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping("/monitor/{cnrId}/{ledId}") |
| | | public void monitor(@PathVariable("cnrId") Integer cnrId, |
| | | @PathVariable("ledId") Integer ledId, |
| | | HttpServletResponse response) { |
| | | try{ |
| | | response.sendRedirect(contextPath+"/views/monitor/monitor.html"+ "?" + "crnId=" + cnrId + "&" + "ledId=" + ledId); |
| | | } catch (Exception ex){ |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping("/monitor0/{ledId}") |
| | | public void monitor(@PathVariable("ledId") Integer ledId, |
| | | HttpServletResponse response) { |
| | | try{ |
| | | response.sendRedirect(contextPath+"/views/monitor/monitor0.html"+ "?" + "crnId=" + 2 + "&" + "ledId=" + ledId); |
| | | } catch (Exception ex){ |
| | | ex.printStackTrace(); |
| | | } |