我有一个spring boot应用程序,其中tomcat通过HTTPS在端口8000上侦听。但是,当端口8000被普通的http请求击中时,服务器将以http 400进行响应。
package Lab8;
import java.util.*;
import java.util.Scanner;
public class Question_One {
public static void main(String args[]) {
int length;
Scanner input = new Scanner(System.in); //scanner to input any size array user wants
System.out.println("Please enter the numbers for the array.");
length = input.nextInt();
String[] array = new String[length];
for(int i = 0;i <length;i++) { //counter logic
System.out.println("How many integers are in the array?"+(i+1));
array[i] = input.nextLine();
}
System.out.println("Enter the numbers for the array (individually):");
for(int i = 0;i <length;i++) { //counter logic
System.out.print(array [i]);
array[i] = input.nextLine();
}
input.close();
minGap(array);
}
private static int minGap(int a[], int gapMin) {
int []gap = new int[a.length];
//a
for (int i=0;i<a.length-2;i++) {
if (gapMin>gap[i]) {
gapMin=gap[1];
}
}
return gapMin;
}
}
有没有办法防止这种情况?我不希望服务器在请求http://localhost:8000时发送任何响应。 Spring Boot和tomcat版本如下:
Bad Request
This combination of host and port requires TLS.
更新:application.properties如下
sprint-boot v2.0.0.RELEASE
tomcat v8.5.28
答案 0 :(得分:1)
您启用了SSL,只需更改server.ssl.enabled=true to
server.ssl.enabled = false