🎉 init spring-security

This commit is contained in:
Bunny 2025-07-08 17:15:03 +08:00
parent 25a7536882
commit 046cfa2c7f
31 changed files with 1924 additions and 25 deletions

View File

@ -14,27 +14,27 @@
<StackPanel Grid.Column="0" Width="200" Margin="5"> <StackPanel Grid.Column="0" Width="200" Margin="5">
<StackPanel Orientation="Horizontal" Margin="0,0,0,5"> <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
<Label Width="60" VerticalAlignment="Center">串口:</Label> <Label Width="60" VerticalAlignment="Center">串口:</Label>
<ComboBox Width="100" Height="28" ItemsSource="{Binding SerialPortNames}" SelectedIndex="0" /> <ComboBox Width="100" Height="28" ItemsSource="{Binding SerialPortModel.SerialPortNames}" SelectedIndex="0" />
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,5"> <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
<Label Width="60" VerticalAlignment="Center">波特率:</Label> <Label Width="60" VerticalAlignment="Center">波特率:</Label>
<ComboBox Width="100" Height="28" ItemsSource="{Binding BaudRates}" SelectedIndex="0" /> <ComboBox Width="100" Height="28" ItemsSource="{Binding SerialPortModel.BaudRates}" SelectedIndex="0" />
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,5"> <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
<Label Width="60" VerticalAlignment="Center">数据位:</Label> <Label Width="60" VerticalAlignment="Center">数据位:</Label>
<ComboBox Width="100" Height="28" ItemsSource="{Binding DataBits}" SelectedIndex="0" /> <ComboBox Width="100" Height="28" ItemsSource="{Binding SerialPortModel.DataBits}" SelectedIndex="0" />
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,5"> <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
<Label Width="60" VerticalAlignment="Center">校验位:</Label> <Label Width="60" VerticalAlignment="Center">校验位:</Label>
<ComboBox Width="100" Height="28" ItemsSource="{Binding ParityList}" SelectedIndex="0" /> <ComboBox Width="100" Height="28" ItemsSource="{Binding SerialPortModel.ParityList}" SelectedIndex="0" />
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10"> <StackPanel Orientation="Horizontal" Margin="0,0,0,10">
<Label Width="60" VerticalAlignment="Center">停止位:</Label> <Label Width="60" VerticalAlignment="Center">停止位:</Label>
<ComboBox Width="100" Height="28" ItemsSource="{Binding StopBitsList}" SelectedIndex="0" /> <ComboBox Width="100" Height="28" ItemsSource="{Binding SerialPortModel.StopBitsList}" SelectedIndex="0" />
</StackPanel> </StackPanel>
<Button Height="32" Margin="0,5,0,0" FontWeight="Bold" Command="{Binding }">打开串口</Button> <Button Height="32" Margin="0,5,0,0" FontWeight="Bold" Command="{Binding }">打开串口</Button>

View File

@ -1,5 +1,6 @@
using System.IO.Ports; using System.IO.Ports;
using System.Windows; using System.Windows;
using Base_2_Window.Model;
using Base_2_Window.ViewModel; using Base_2_Window.ViewModel;
namespace Base_2_Window; namespace Base_2_Window;
@ -13,14 +14,14 @@ public partial class MainWindow : Window
{ {
InitializeComponent(); InitializeComponent();
DataContext = new MainWindowViewModel DataContext = new MainWindowViewModel();
{ Command = new OpenSerialPortCommand(OpenPort);
SerialPortNames = SerialPort.GetPortNames().Select(s => s).ToList(), }
BaudRates = new List<int> { 9600 },
DataBits = new List<int> { 6, 7, 8 }, public OpenSerialPortCommand Command { get; set; }
StopBitsList = new List<StopBits> { StopBits.None, StopBits.One, StopBits.Two, StopBits.OnePointFive },
ParityList = new List<Parity> public void OpenPort()
{ Parity.None, Parity.Even, Parity.Mark, Parity.None, Parity.Odd, Parity.Space } {
};
} }
} }

View File

@ -6,9 +6,11 @@ public class SerialPortModel
{ {
public List<string>? SerialPortNames { get; set; } public List<string>? SerialPortNames { get; set; }
public int? BaudRate { get; set; } public List<int>? BaudRates { get; set; }
public int? DataBits { get; set; } public List<StopBits>? StopBitsList { get; set; }
public StopBits? StopBits { get; set; } public List<Parity>? ParityList { get; set; }
public List<int>? DataBits { get; set; }
} }

View File

@ -1,17 +1,23 @@
using System.IO.Ports; using System.IO.Ports;
using Base_2_Window.Model;
using Base_2_Window.MVVM; using Base_2_Window.MVVM;
namespace Base_2_Window.ViewModel; namespace Base_2_Window.ViewModel;
public class MainWindowViewModel : ViewModelBase public class MainWindowViewModel : ViewModelBase
{ {
public List<string>? SerialPortNames { get; set; } public MainWindowViewModel()
{
SerialPortModel = new SerialPortModel()
{
SerialPortNames = SerialPort.GetPortNames().Select(s => s).ToList(),
BaudRates = new List<int> { 9600 },
DataBits = new List<int> { 6, 7, 8 },
StopBitsList = new List<StopBits> { StopBits.None, StopBits.One, StopBits.Two, StopBits.OnePointFive },
ParityList = new List<Parity>
{ Parity.None, Parity.Even, Parity.Mark, Parity.None, Parity.Odd, Parity.Space }
};;
}
public List<int>? BaudRates { get; set; } public SerialPortModel SerialPortModel { get; set; }
public List<StopBits>? StopBitsList { get; set; }
public List<Parity>? ParityList { get; set; }
public List<int>? DataBits { get; set; }
} }

View File

@ -0,0 +1,25 @@
using System.Windows.Input;
namespace Base_2_Window.ViewModel;
public class OpenSerialPortCommand:ICommand
{
public OpenSerialPortCommand(Action execute)
{
_execute = execute;
}
private readonly Action _execute;
public bool CanExecute(object? parameter)
{
return true;
}
public void Execute(object? parameter)
{
_execute();
}
public event EventHandler? CanExecuteChanged;
}

View File

@ -139,6 +139,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo-TODO", "Demo-TODO\Demo
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASP-Demo-TODO", "ASP-Demo-TODO\ASP-Demo-TODO.csproj", "{5C964709-FAFB-4674-A59F-564D8F704D93}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASP-Demo-TODO", "ASP-Demo-TODO\ASP-Demo-TODO.csproj", "{5C964709-FAFB-4674-A59F-564D8F704D93}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WPFReview", "WPFReview", "{1AD7076E-2F79-45A6-907E-B9FA503C5DE3}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU

139
spring-security/pom.xml Normal file
View File

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.mall</groupId>
<artifactId>spring-security</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-security</name>
<description>spring-security</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<java.version>17</java.version>
<knife4j.version>4.5.0</knife4j.version>
<font-awesome.version>5.15.4</font-awesome.version>
<bootstrap.version>5.1.3</bootstrap.version>
<jquery.version>3.6.0</jquery.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.47</version>
</dependency>
<!-- knife 4 j-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
</dependency>
<!-- 前端美化相关 -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>${bootstrap.version}</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>${font-awesome.version}</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>${jquery.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,11 @@
package com.spring;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringSecurityApplication {
public static void main(String[] args) {
SpringApplication.run(SpringSecurityApplication.class, args);
}
}

View File

@ -0,0 +1,33 @@
package com.spring.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationEventPublisher;
import org.springframework.security.authentication.DefaultAuthenticationEventPublisher;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
@EnableWebSecurity
@Configuration
public class DefaultSecurityConfig {
@Bean
@ConditionalOnMissingBean(UserDetailsService.class)
InMemoryUserDetailsManager inMemoryUserDetailsManager() {
String generatedPassword = PasswordEncoderFactories.createDelegatingPasswordEncoder()
.encode("123456");
return new InMemoryUserDetailsManager(User.withUsername("user")
.password(generatedPassword).roles("USER").build());
}
@Bean
@ConditionalOnMissingBean(AuthenticationEventPublisher.class)
DefaultAuthenticationEventPublisher defaultAuthenticationEventPublisher(ApplicationEventPublisher delegate) {
return new DefaultAuthenticationEventPublisher(delegate);
}
}

View File

@ -0,0 +1,44 @@
package com.spring.config;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@Slf4j
public class Knife4jConfig {
@Value("${server.port}")
private String port;
@Bean
public OpenAPI openAPI() {
String url = "http://localhost:" + port;
// 作者等信息
Contact contact = new Contact().name("Bunny").email("1319900154@qq.com").url(url);
// 使用协议
License license = new License().name("MIT").url("https://mit-license.org");
// 相关信息
Info info = new Info().title("Bunny-Admin")
.contact(contact).license(license)
.description("Bunny代码生成器")
.summary("Bunny的代码生成器")
.termsOfService(url)
.version("v1.0.0");
return new OpenAPI().info(info).externalDocs(new ExternalDocumentation());
}
@Bean
public GroupedOpenApi all() {
return GroupedOpenApi.builder().group("全部请求接口").pathsToMatch("/api/**").build();
}
}

View File

@ -0,0 +1,12 @@
server:
port: 8800
spring:
application:
name: spring-security
logging:
level:
com.spring: debug
root: info

View File

@ -0,0 +1,11 @@
____ ____ _ _
| __ ) _ _ _ __ _ __ _ _ / ___|| |_ _ _ __| |_ _
| _ \| | | | '_ \| '_ \| | | | \___ \| __| | | |/ _` | | | |
| |_) | |_| | | | | | | | |_| | ___) | |_| |_| | (_| | |_| |
|____/ \__,_|_| |_|_| |_|\__, | |____/ \__|\__,_|\__,_|\__, |
|___/ |___/
Service Name${spring.application.name}
SpringBoot Version: ${spring-boot.version}${spring-boot.formatted-version}
Spring Active${spring.profiles.active}

View File

@ -0,0 +1,108 @@
/* devanagari */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 300;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiByp8kv8JHgFVrLDz8Z11lFc-K.woff2) format('woff2');
unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}
/* latin-ext */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 300;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiByp8kv8JHgFVrLDz8Z1JlFc-K.woff2) format('woff2');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 300;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiByp8kv8JHgFVrLDz8Z1xlFQ.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* devanagari */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiEyp8kv8JHgFVrJJbecmNE.woff2) format('woff2');
unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}
/* latin-ext */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiEyp8kv8JHgFVrJJnecmNE.woff2) format('woff2');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiEyp8kv8JHgFVrJJfecg.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* devanagari */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 600;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiByp8kv8JHgFVrLEj6Z11lFc-K.woff2) format('woff2');
unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}
/* latin-ext */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 600;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiByp8kv8JHgFVrLEj6Z1JlFc-K.woff2) format('woff2');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 600;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiByp8kv8JHgFVrLEj6Z1xlFQ.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* devanagari */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiByp8kv8JHgFVrLCz7Z11lFc-K.woff2) format('woff2');
unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}
/* latin-ext */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiByp8kv8JHgFVrLCz7Z1JlFc-K.woff2) format('woff2');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v23/pxiByp8kv8JHgFVrLCz7Z1xlFQ.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

View File

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>400 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 200px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>HTTP 400 - Bad Request</h1>
<dl>
<dt>错误说明:因为错误的语法导致服务器无法理解请求信息。</dt>
<dt>原因1客户端发起的请求不符合服务器对请求的某些限制或者请求本身存在一定的错误。</dt>
<dd>解决办法:</dd>
<dd>链接中有特殊字符或者链接长度过长导致,请对应修改.</dd>
<dt>原因2request header 或者 cookie 过大所引起</dt>
<dd>解决办法:</dd>
<dd>crtl+shift+delete 快捷键清除cookie.</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>403 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 200px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>403 - Forbidden 禁止访问: 访问被拒绝</h1>
<dl>
<dt>错误说明:禁止访问,服务器拒绝访问</dt>
<dt>原因1未找到默认的索引文件</dt>
<dd>解决办法:</dd>
<dd>IIS中【启用默认内容文档】选项中将默认打开文档修改为程序首页文件格式index.html或者index.php</dd>
<dt>原因2文件夹安全权限导致</dt>
<dd>解决办法:</dd>
<dd>程序文件-右击-属性-安全-Users-修改为读取和执行权限</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>404 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 50px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>404 - Page Not Found 未找到</h1>
<dl>
<dt>错误说明:请求的页面不存在</dt>
<dt>原因1访问的文档权限不够</dt>
<dd>解决办法:</dd>
<dd>修改文件权限为755windos系统修改目录权限为可写可读。</dd>
<dt>原因2防火墙的原因</dt>
<dd>解决办法:</dd>
<dd>先关闭让防火墙通过WWW服务。</dd>
<dt>原因3站点根目录无默认访问文件</dt>
<dd>解决办法:</dd>
<dd>在根目录中创建index.html或者创建index.php。</dd>
<dt>原因4站点配置目录不正确</dt>
<dd>解决办法:</dd>
<dd>将网站应用程序复制到站点目录中,或者修改站点配置目录指定到应用程序目录中。</dd>
<dt>原因5站点使用了伪静态</dt>
<dd>解决办法:</dd>
<dd>将伪静态规则删除,或者重新编写正确的伪静态规则,或关闭伪静态配置。</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<title>500 - 服务器错误</title>
<meta content="width=device-width, maximum-scale=1, initial-scale=1" name="viewport"/>
<style>
html, body {
height: 100%;
}
body {
color: #333;
margin: auto;
padding: 1em;
display: table;
user-select: none;
box-sizing: border-box;
font: lighter 20px "微软雅黑";
}
a {
color: #3498db;
text-decoration: none;
}
h1 {
margin-top: 0;
font-size: 3.5em;
}
main {
margin: 0 auto;
text-align: center;
display: table-cell;
vertical-align: middle;
}
.btn {
color: #fff;
padding: .75em 1em;
background: #3498db;
border-radius: 1.5em;
display: inline-block;
transition: opacity .3s, transform .3s;
}
.btn:hover {
transform: scale(1.1);
}
.btn:active {
opacity: .7;
}
</style>
</head>
<body>
<main>
<h1>:'(</h1>
<p>服务器开小差啦!管理员正在修理中...</p>
<p>还请阁下静候站点恢复~</p>
</main>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>501 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 200px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>HTTP 501 - Not Implemented</h1>
<dl>
<dt>错误说明:服务器没有相应的执行动作来完成当前请求。</dt>
<dt>原因1Web 服务器不支持实现此请求所需的功能</dt>
<dd>解决办法:</dd>
<dd>可以用来HttpWebRequest指定一个UserAgent来试试的有时候你可以换电脑来测试一下的。</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>502 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 50px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>HTTP 502 - Bad Gateway 没有响应</h1>
<dl>
<dt>错误说明坏的网关http向后端节点请求没有响应</dt>
<dt>原因1DNS 缓冲</dt>
<dd>解决办法:</dd>
<dd>在dos窗口运行 ipconfig /flushdns该命令会刷新DNS缓冲。</dd>
<dt>原因2浏览器代理</dt>
<dd>解决办法:</dd>
<dd>关掉代理。</dd>
<dt>原因3dns 被劫持了即使使用国外的dns也会被劫持</dt>
<dd>解决办法:</dd>
<dd>
去掉VPN服务器的DNS。切换另外的dns。在windows系统中可以在本地网络连接的属性中去掉默认的dns选用国外的dns比如google的或opendns。
</dd>
<dt>原因4php执行超时</dt>
<dd>解决办法:</dd>
<dd>修改/usr/local/php/etc/php.ini 将max_execution_time 改为300。</dd>
<dt>原因5nginx等待时间超时</dt>
<dd>解决办法:</dd>
<dd>适当增加nginx.conf配置文件中FastCGI的timeout时间。</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>503 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 200px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>HTTP 503 - Service Unavailable 服务不可用</h1>
<dl>
<dt>错误说明:服务当前不可用</dt>
<dt>原因1服务不可用状态</dt>
<dd>解决办法:</dd>
<dd>服务器或许就是正在维护或者暂停了,你可以联系一下服务器空间商。</dd>
<dt>原因2程序占用资源太多</dt>
<dd>解决办法:</dd>
<dd>通过设置应用程序池把账户改为NetworkService即可解决。</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>504 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 50px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>HTTP 504 - Gateway Timeout 网关超时</h1>
<dl>
<dt>错误说明:网关超时,服务器响应时间,达到超出设定的范围</dt>
<dt>原因1后端电脑之间 IP 通讯缓慢而产生</dt>
<dd>解决办法:</dd>
<dd>如果您的 Web 服务器由某一网站托管, 只有负责那个网站设置的人员才能解决这个问题。</dd>
<dt>原因2由于nginx默认的fastcgi进程响应的缓冲区太小造成的错误</dt>
<dd>解决办法:</dd>
<dd>一般默认的fastcgi进程响应的缓冲区是8K这时可以设置大一点在nginx.conf里加入fastcgi_buffers 8
128k这表示设置fastcgi缓冲区为8块128k大小的空间。当然如果在进行某一项即时的操作, 可能需要nginx的超时参数调大点,
例如设置成60秒:send_timeout 60;经过这两个参数的调整一般不会再提示“504 Gateway Time-out”错误问题基本解决。
</dd>
<dt>原因3PHP环境的配置问题</dt>
<dd>解决办法:</dd>
<dd>更改php-fpm的几处配置 把max_children由之前的10改为现在的30这样就可以保证有充足的php-cgi进程可以被使用
把request_terminate_timeout由之前的0s改为60s这样php-cgi进程 处理脚本的超时时间就是60秒可以防止进程都被挂起提高利用效率。
接着再更改nginx的几个配置项减少FastCGI的请求次数尽量维持buffers不变 fastcgi_buffers由 4 64k 改为 2
256k fastcgi_buffer_size 由 64k 改为 128K fastcgi_busy_buffers_size 由 128K 改为 256K
fastcgi_temp_file_write_size 由 128K 改为 256K。 重新加载php-fpm和nginx的配置再次测试如果没有出现“504
Gateway Time-out”错误问题解决。
</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>505 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 200px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>HTTP 505 - HTTP Version Not Supported</h1>
<dl>
<dt>错误说明HTTP 版本不受支持。</dt>
<dt>原因1您的 Web 服务器不支持,或拒绝支持客户端(如您的浏览器)在发送给服务器的 HTTP 请求数据流中指定的 HTTP
协议版本
</dt>
<dd>解决办法:</dd>
<dd>升级您的 Web 服务器软件。</dd>
<dt>原因2http请求格式的错误</dt>
<dd>解决办法:</dd>
<dd>对照一下自己的代码从打印的信息中终于找到问题所在。可能在请求后面多加了一个空格。http协议真是很严格了。
</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>506 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 200px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>HTTP 506 - Variant Also Negotiates</h1>
<dl>
<dt>错误说明:</dt>
<dt>原因1服务器存在内部配置错误</dt>
<dd>解决办法:</dd>
<dd>被请求的协商变元资源被配置为在透明内容协商中使用自己,因此在一个协商处理中不是一个合适的重点。</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>507 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 200px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>HTTP 507 - Insufficient Storage</h1>
<dl>
<dt>错误说明:</dt>
<dt>原因1服务器无法存储完成请求所必须的内容</dt>
<dd>解决办法:</dd>
<dd>这个状况被认为是临时的。WebDAV (RFC 4918)。</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>509 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 200px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>HTTP 509 - Bandwidth Limit Exceeded</h1>
<dl>
<dt>错误说明:</dt>
<dt>原因1网站流量已经超出您所购买的方案限制即服务器达到带宽限制</dt>
<dd>解决办法:</dd>
<dd>1.升级方案 2.等到下个月后流量重新计算,网站即可正常浏览。</dd>
</dl>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>510 错误 - phpstudy</title>
<meta content="" name="keywords">
<meta content="" name="description">
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
<meta CONTENT="0" HTTP-EQUIV="expires">
<style>
body {
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
h1 {
margin: 0;
color: #3a87ad;
font-size: 26px;
}
.content {
width: 45%;
margin: 0 auto;
}
.content > div {
margin-top: 200px;
padding: 20px;
background: #d9edf7;
border-radius: 12px;
}
.content dl {
color: #2d6a88;
line-height: 40px;
}
.content div div {
padding-bottom: 20px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<div>
<h1>HTTP 510 - Not Extended</h1>
<dl>
<dt>错误说明:</dt>
<dt>原因1获取资源所需要的策略并没有被满足</dt>
<dd>解决办法:</dd>
<dd>需要请求有额外的扩展内容,服务器才能处理请求。</dd>
</dl>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -0,0 +1,502 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Spring Security 6 学习中心</title>
<link th:href="@{/css/css2.css}">
<!-- Bootstrap CSS -->
<link rel="stylesheet" th:href="@{/webjars/bootstrap/5.1.3/css/bootstrap.min.css}">
<!-- Font Awesome -->
<link rel="stylesheet" th:href="@{/webjars/font-awesome/5.15.4/css/all.min.css}">
<style>
:root {
--primary: #4a6bff;
--secondary: #6c757d;
--success: #28a745;
--danger: #dc3545;
--light: #f8f9fa;
--dark: #343a40;
--gradient-start: #667eea;
--gradient-end: #764ba2;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
background-color: #f5f7ff;
color: #333;
line-height: 1.6;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
/* 导航栏 */
header {
background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
color: white;
padding: 20px 0;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
position: fixed;
width: 100%;
top: 0;
z-index: 1000;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-size: 24px;
font-weight: 700;
display: flex;
align-items: center;
}
.logo i {
margin-right: 10px;
color: #ffcc00;
}
.nav-links {
display: flex;
list-style: none;
}
.nav-links li {
margin-left: 30px;
}
.nav-links a {
color: white;
text-decoration: none;
font-weight: 500;
transition: all 0.3s ease;
padding: 8px 12px;
border-radius: 4px;
}
.nav-links a:hover {
background-color: rgba(255, 255, 255, 0.2);
}
/* 英雄区域 */
.hero {
height: 100vh;
display: flex;
align-items: center;
background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('https://images.unsplash.com/photo-1550751827-4bd374c3f58b?ixlib=rb-4.0.3&auto=format&fit=crop&w=1350&q=80');
background-size: cover;
background-position: center;
color: white;
text-align: center;
padding-top: 80px;
}
.hero-content {
max-width: 800px;
margin: 0 auto;
}
.hero h1 {
font-size: 3.5rem;
margin-bottom: 20px;
line-height: 1.2;
}
.hero p {
font-size: 1.2rem;
margin-bottom: 30px;
opacity: 0.9;
}
.btn {
display: inline-block;
padding: 12px 30px;
background-color: var(--primary);
color: white;
text-decoration: none;
border-radius: 50px;
font-weight: 600;
transition: all 0.3s ease;
border: none;
cursor: pointer;
margin: 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}
.btn:hover {
transform: translateY(-3px);
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
background-color: #3a56d4;
}
.btn-outline {
background-color: transparent;
border: 2px solid white;
}
.btn-outline:hover {
background-color: white;
color: var(--primary);
}
/* 特性部分 */
.features {
padding: 100px 0;
background-color: white;
}
.section-title {
text-align: center;
margin-bottom: 60px;
}
.section-title h2 {
font-size: 2.5rem;
color: var(--dark);
margin-bottom: 15px;
}
.section-title p {
color: var(--secondary);
max-width: 700px;
margin: 0 auto;
}
.features-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 30px;
}
.feature-card {
background-color: var(--light);
padding: 30px;
border-radius: 10px;
text-align: center;
transition: all 0.3s ease;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}
.feature-card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}
.feature-icon {
font-size: 3rem;
color: var(--primary);
margin-bottom: 20px;
}
.feature-card h3 {
font-size: 1.5rem;
margin-bottom: 15px;
color: var(--dark);
}
/* 文档部分 */
.docs {
padding: 100px 0;
background-color: #f5f7ff;
}
.docs-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 30px;
}
.doc-card {
background-color: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
transition: all 0.3s ease;
}
.doc-card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}
.doc-image {
height: 200px;
background-size: cover;
background-position: center;
}
.doc-card:nth-child(1) .doc-image {
background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url('https://images.unsplash.com/photo-1551288049-bebda4e38f71?ixlib=rb-4.0.3&auto=format&fit=crop&w=1350&q=80');
}
.doc-card:nth-child(2) .doc-image {
background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url('https://images.unsplash.com/photo-1461749280684-dccba630e2f6?ixlib=rb-4.0.3&auto=format&fit=crop&w=1350&q=80');
}
.doc-content {
padding: 30px;
}
.doc-content h3 {
font-size: 1.5rem;
margin-bottom: 15px;
color: var(--dark);
}
.doc-content p {
color: var(--secondary);
margin-bottom: 20px;
}
/* 页脚 */
footer {
background-color: var(--dark);
color: white;
padding: 60px 0 20px;
}
.footer-content {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 40px;
margin-bottom: 40px;
}
.footer-column h3 {
font-size: 1.3rem;
margin-bottom: 20px;
position: relative;
padding-bottom: 10px;
}
.footer-column h3::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 50px;
height: 2px;
background-color: var(--primary);
}
.footer-column p {
opacity: 0.8;
margin-bottom: 15px;
}
.footer-links {
list-style: none;
}
.footer-links li {
margin-bottom: 10px;
}
.footer-links a {
color: white;
text-decoration: none;
opacity: 0.8;
transition: all 0.3s ease;
}
.footer-links a:hover {
opacity: 1;
padding-left: 5px;
}
.social-links {
display: flex;
gap: 15px;
}
.social-links a {
display: inline-flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
background-color: rgba(255, 255, 255, 0.1);
border-radius: 50%;
color: white;
transition: all 0.3s ease;
}
.social-links a:hover {
background-color: var(--primary);
transform: translateY(-3px);
}
.footer-bottom {
text-align: center;
padding-top: 20px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
opacity: 0.7;
font-size: 0.9rem;
}
/* 响应式设计 */
@media (max-width: 768px) {
.hero h1 {
font-size: 2.5rem;
}
.hero p {
font-size: 1rem;
}
.nav-links {
display: none;
}
.features-grid, .docs-cards {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<!-- 导航栏 -->
<header>
<div class="container">
<nav>
<div class="logo">
<i class="fas fa-shield-alt"></i>
<span>Spring Security 6</span>
</div>
<ul class="nav-links">
<li><a href="#features" target="_blank">特性</a></li>
<li><a href="#docs" target="_blank">文档</a></li>
<li><a href="/doc.html" target="_blank">API 文档</a></li>
<li><a href="/swagger-ui/index.html" target="_blank">Swagger UI</a></li>
</ul>
</nav>
</div>
</header>
<!-- 英雄区域 -->
<section class="hero">
<div class="container">
<div class="hero-content">
<h1>掌握 Spring Security 6</h1>
<p>学习最强大的Java安全框架保护您的应用程序免受现代安全威胁。Spring Security
6提供了全面的身份验证和授权功能让您的应用安全无忧。</p>
<div>
<a class="btn" href="#docs" target="_blank">开始学习</a>
<a class="btn btn-outline" href="/doc.html" target="_blank">查看API文档</a>
</div>
</div>
</div>
</section>
<!-- 特性部分 -->
<section class="features" id="features">
<div class="container">
<div class="section-title">
<h2>Spring Security 6 核心特性</h2>
<p>Spring Security 6引入了许多强大的新功能使应用程序安全比以往任何时候都更简单、更强大。</p>
</div>
<div class="features-grid">
<div class="feature-card">
<div class="feature-icon">
<i class="fas fa-user-lock"></i>
</div>
<h3>现代化的认证</h3>
<p>支持OAuth 2.0、OpenID Connect、SAML 2.0等多种认证协议,满足现代应用的安全需求。</p>
</div>
<div class="feature-card">
<div class="feature-icon">
<i class="fas fa-key"></i>
</div>
<h3>强大的授权</h3>
<p>细粒度的权限控制,支持方法级安全、领域对象安全等多种授权模式。</p>
</div>
<div class="feature-card">
<div class="feature-icon">
<i class="fas fa-shield-virus"></i>
</div>
<h3>防护机制</h3>
<p>内置CSRF防护、点击劫持防护、内容安全策略等安全机制保护应用免受常见攻击。</p>
</div>
</div>
</div>
</section>
<!-- 文档部分 -->
<section class="docs" id="docs">
<div class="container">
<div class="section-title">
<h2>学习资源与文档</h2>
<p>探索我们的文档和工具快速掌握Spring Security 6的强大功能。</p>
</div>
<div class="docs-cards">
<div class="doc-card">
<div class="doc-image"></div>
<div class="doc-content">
<h3>API 文档</h3>
<p>详细的API参考文档包含所有类、方法和配置选项的详细说明帮助您充分利用Spring Security
6的所有功能。</p>
<a class="btn" href="/doc.html" target="_blank">查看API文档</a>
</div>
</div>
<div class="doc-card">
<div class="doc-image"></div>
<div class="doc-content">
<h3>Swagger UI</h3>
<p>交互式API文档可以直接在浏览器中测试API端点查看请求和响应示例加快开发流程。</p>
<a class="btn" href="/swagger-ui/index.html" target="_blank">访问Swagger UI</a>
</div>
</div>
</div>
</div>
</section>
<!-- 页脚 -->
<footer>
<div class="container">
<div class="footer-content">
<div class="footer-column">
<h3>关于 Spring Security</h3>
<p>Spring
Security是一个功能强大且高度可定制的身份验证和访问控制框架是保护基于Spring的应用程序的事实标准。</p>
<div class="social-links">
<a href="#"><i class="fab fa-github"></i></a>
<a href="#"><i class="fab fa-twitter"></i></a>
<a href="#"><i class="fab fa-stack-overflow"></i></a>
</div>
</div>
<div class="footer-column">
<h3>快速链接</h3>
<ul class="footer-links">
<li><a href="#features" target="_blank">核心特性</a></li>
<li><a href="#docs" target="_blank">学习资源</a></li>
<li><a href="/doc.html" target="_blank">API文档</a></li>
<li><a href="/swagger-ui/index.html" target="_blank">Swagger UI</a></li>
</ul>
</div>
<div class="footer-column">
<h3>联系我们</h3>
<p><i class="fas fa-envelope"></i> security@example.com</p>
<p><i class="fas fa-globe"></i> www.springsecurity.org</p>
</div>
</div>
<div class="footer-bottom">
<p>&copy; 2023 Spring Security 学习中心. 保留所有权利.</p>
</div>
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,13 @@
package com.spring;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SpringSecurityApplicationTests {
@Test
void contextLoads() {
}
}

View File

@ -0,0 +1,24 @@
package com.spring.context;
import com.alibaba.fastjson2.JSON;
import org.junit.jupiter.api.Test;
import org.springframework.security.authentication.TestingAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
public class SecurityContextHolderTest {
@Test
void testSecurityContextHolder() {
SecurityContext context = SecurityContextHolder.createEmptyContext();
Authentication authentication = new TestingAuthenticationToken("username", "password", "ROLE_USER");
context.setAuthentication(authentication);
SecurityContextHolder.setContext(context);
SecurityContext securityContext = SecurityContextHolder.getContext();
Authentication contextAuthentication = securityContext.getAuthentication();
System.out.println(JSON.toJSON(contextAuthentication));
}
}

View File

@ -0,0 +1,54 @@
package com.spring.password;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.encrypt.BytesEncryptor;
import org.springframework.security.crypto.encrypt.Encryptors;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.keygen.KeyGenerators;
import org.springframework.security.crypto.password.PasswordEncoder;
@Slf4j
public class PasswordTest {
@Test
void passwordEncoderTest() {
PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
String encode = passwordEncoder.encode("123456");
log.info("PasswordEncoder 加密密码:{}", encode);
boolean matches = passwordEncoder.matches("123456", encode);
log.info("PasswordEncoder 是否匹配:{}", matches);
}
@Test
void UserDetailTest() {
UserDetails user = User.builder()
.username("user")
.password("123456")
.roles("user")
.build();
UserDetails password = User.withUserDetails(user).password("123456").build();
System.out.println(password.getPassword());// 123456
}
@Test
void EncryptorsTest() {
String salt = KeyGenerators.string().generateKey(); // generates a random 8-byte salt that is then hex-encoded
String string = "password";
BytesEncryptor bytesEncryptor = Encryptors.stronger(string, salt);
byte[] encrypted = bytesEncryptor.encrypt(string.getBytes());
byte[] decrypt = bytesEncryptor.decrypt(string.getBytes());
TextEncryptor password = Encryptors.text(string, salt);
String encrypt = password.encrypt(string);
String decrypted = password.decrypt(encrypt);
System.out.println(encrypt);
System.out.println(decrypted);
}
}