From f29d61e0b46586730d322b53b068113fe5acbf31 Mon Sep 17 00:00:00 2001 From: huwentao Date: Fri, 14 Jan 2022 22:53:11 +0800 Subject: [PATCH 1/5] =?UTF-8?q?refactor=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=B7=E5=BC=8F,=E6=B7=BB=E5=8A=A0gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++ .../com/education/config/MyServletConfig.java | 4 +- .../{Myservlet.java => RdpServlet.java} | 12 ++---- src/main/resources/templates/guacamole.html | 37 ++++++++----------- 4 files changed, 24 insertions(+), 32 deletions(-) create mode 100644 .gitignore rename src/main/java/com/education/servlet/{Myservlet.java => RdpServlet.java} (90%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b96e62d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/log/ +/target/ +/.idea/ diff --git a/src/main/java/com/education/config/MyServletConfig.java b/src/main/java/com/education/config/MyServletConfig.java index c657ff6..eec3cbc 100644 --- a/src/main/java/com/education/config/MyServletConfig.java +++ b/src/main/java/com/education/config/MyServletConfig.java @@ -1,6 +1,6 @@ package com.education.config; -import com.education.servlet.Myservlet; +import com.education.servlet.RdpServlet; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -15,7 +15,7 @@ public class MyServletConfig { @Bean //注册servlet组件 public ServletRegistrationBean myServlet(){ - ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new Myservlet(), + ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new RdpServlet(), "/rdpview/*"); return servletRegistrationBean; } diff --git a/src/main/java/com/education/servlet/Myservlet.java b/src/main/java/com/education/servlet/RdpServlet.java similarity index 90% rename from src/main/java/com/education/servlet/Myservlet.java rename to src/main/java/com/education/servlet/RdpServlet.java index 4f39ac8..56c9913 100644 --- a/src/main/java/com/education/servlet/Myservlet.java +++ b/src/main/java/com/education/servlet/RdpServlet.java @@ -1,7 +1,6 @@ package com.education.servlet; import com.education.config.GuacamoleConfig; -import com.education.config.RdpViewConfig; import lombok.extern.slf4j.Slf4j; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.net.GuacamoleSocket; @@ -12,10 +11,8 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration; import org.apache.guacamole.servlet.GuacamoleHTTPTunnelServlet; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; -import javax.xml.ws.soap.Addressing; import java.util.Arrays; import java.util.List; @@ -25,14 +22,13 @@ * Explain: */ @Slf4j -public class Myservlet extends GuacamoleHTTPTunnelServlet { +public class RdpServlet extends GuacamoleHTTPTunnelServlet { @Autowired private GuacamoleConfig guacamoleConfig; @Override - protected GuacamoleTunnel doConnect(HttpServletRequest request) - throws GuacamoleException { + protected GuacamoleTunnel doConnect(HttpServletRequest request) { try { List info = Arrays.asList(request.getRequestURI().split("/rdpview/")[1].split("&")); // Create our configuration @@ -50,11 +46,11 @@ protected GuacamoleTunnel doConnect(HttpServletRequest request) config.setParameter("security","nla"); // 忽略证书验证,否则guaced 会报错 config.setParameter("ignore-cert","true"); - // Connect to guacd - everything is hard-coded here. GuacamoleSocket socket = new ConfiguredGuacamoleSocket( + new InetGuacamoleSocket("localhost", 4822), // Todo 学习Servlet 整合springboot 将配置放在yml中,之前一直未成功 - new InetGuacamoleSocket("127.0.0.1", 4822), +// new InetGuacamoleSocket("127.0.0.1", 4822), config ); diff --git a/src/main/resources/templates/guacamole.html b/src/main/resources/templates/guacamole.html index 8766176..f2490cf 100644 --- a/src/main/resources/templates/guacamole.html +++ b/src/main/resources/templates/guacamole.html @@ -2,7 +2,7 @@ - 360考试认证平台 + 快贸-远程桌面 @@ -16,24 +16,20 @@ @@ -54,36 +50,33 @@