技术标签: Javaweb系列笔记
@ConfigurationProperties(
prefix = "server",
ignoreUnknownFields = false
)
public class ServerProperties implements EmbeddedServletContainerCustomizer, Ordered {
private Integer port;
private InetAddress address;
private Integer sessionTimeout;
private String contextPath;
private String displayName = "application";
@NestedConfigurationProperty
private Ssl ssl;
@NotNull
private String servletPath = "/";
private final ServerProperties.Tomcat tomcat = new ServerProperties.Tomcat();
private final ServerProperties.Undertow undertow = new ServerProperties.Undertow();
@NestedConfigurationProperty
private JspServlet jspServlet;
private final Map<String, String> contextParameters = new HashMap();
}
server.port = #配置程序的端口,供外部设备访问,默认为8080
server.seesion-timeout=#用户会话 session 的过期时间,以秒为单位
server.context-path=#配置访问路径,默认为/
server.tomcat.uri-encoding=#配置 Tomcat 编码,默认为 UTF-8
server.tomcat.compression=#Tomcat 是否开启压缩,默认关闭 off
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.ErrorPage;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
@Component
public class CustomServletContainer implements EmbeddedServletContainerCustomizer {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
container.setPort(8888); //设置启动端口
container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,"/404.html")); //设置错误页面
container.setSessionTimeout(10, TimeUnit.MINUTES); //设置访问超时时间
}
}
import com.wisely.ch5_2_3.bean.Person;
import com.wisely.ch5_2_3.config.AuthorSettings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.ErrorPage;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Controller
@SpringBootApplication
public class Ch523Application {
// @Value("${author.name}")
// private String authorName;
// @Value("${author.mail}")
// private String authorMail;
// @Autowired
// private AuthorSettings authorSettings;
@RequestMapping("/")
public String index(Model model){
Person single = new Person("aa",11);
List<Person> people = new ArrayList<>();
Person p1 = new Person("xx",11);
Person p2 = new Person("yy",22);
Person p3 = new Person("zz",33);
people.add(p1);
people.add(p2);
people.add(p3);
model.addAttribute("singlePerson",single);
model.addAttribute("people",people);
return "index";
// return "author name is"+authorSettings.getName()+", age is:"+authorSettings.getAge()
// +", mail is:"+authorSettings.getMail();
// return "Spring Boot Demo Project, "+"author name is:"+authorName
// +", author mail is:"+authorMail;
}
public static void main(String[] args) {
// SpringApplication.run(Ch523Application.class, args);
// SpringApplication app = new SpringApplication(Ch523Application.class);
// app.setShowBanner(false);
// app.run(args);
new SpringApplicationBuilder(Ch523Application.class)
.showBanner(true)
.run(args);
}
@Component
public static class CustomServerContainer implements EmbeddedServletContainerCustomizer{
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
container.setPort(8888); //设置启动端口
container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,"/404.html")); //设置错误页面
container.setSessionTimeout(10, TimeUnit.MINUTES); //设置访问超时时间
}
}
}
@Bean
public EmbeddedServletContainerFactory servletContainer(){
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.setPort(8888);
factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,"/404.html"));
factory.setSessionTimeout(10,TimeUnit.MINUTES);
return factory;
}
<!-- 将 Tomcat 容器替换为 Jetty-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 替换为 Undertow-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
文章浏览阅读1.7k次。一Filter开发步骤1导包2编写过滤器二实战1编写Servlet,用于测试package com.cakin.servlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;/*** @Clas..._servlet 过滤器处理中文乱码
文章浏览阅读501次。PMP 目前还是好考的,只有选择题(大陆地区),技巧很多,可以看看这篇文章,从怎么选择培训机构到如何 5A 通关都有写,应该对你有点帮助~PMP考试并不难,我觉得备考 PMP 就是心态+方法+坚持,能做到这三点通过 PMP 是一件很容易的事情。心态方法>>>技巧一:>>>技巧二:有针对性目的性的刷题,拒绝盲目刷题刷题阶段,其实最好是跟上直播课,上一节课刷一章的练习题,这有助于知识掌握,也不会太赶时间,每次听完串讲后直接刷的模拟试卷,尤其是模考 1、2 、3 套,绝对要刷,我碰到了类似的题(非原题)。但_pmp项目管理证书好考吗
文章浏览阅读692次。使用Jerry这篇文章在Google Cloud platform上的Kubernetes集群部署HANA Express里介绍的方法在Google Cloud Platform的Kubernetes cluster上安装SAP HANA Express.文中介绍了一个yaml文件,里面声明了容器镜像文件store/saplabs/hanaexpress:2.00.033.00.20180925..._连接hana express
文章浏览阅读818次。这段代码用Beep来演奏一段天空之城代码如下:#include <cstdio>#include <windows.h>#define qdo 262 #define qre 294#define qmi 330 //q前缀为低音,1后缀为高音,s前缀为半音阶 #define qfa 349#define qso 392#define qla 440#define qsi 494#define do 523#define re 578#define _c加加编程歌曲
文章浏览阅读6.7k次,点赞6次,收藏23次。这是一个组装软件,运行很快。_spades软件
文章浏览阅读2.3k次。最近在做davinci平台的系统开发,用的是ti公司的dm6446芯片,这款芯片比较经典所以资料也挺多的,而且ti官方给提供一个dvsdk的软件包,里面包含了包括bootloader、kernel、fs、DSP算法及各种编解码codec,可谓给开发者提供了很多便利。当然里面也包含了arm-linux的交叉编译工具链,但是版本比较旧了,是基于gcc-4.2.0版本的,现在最新的gcc的版本已经到了4_达芬奇程序编译
文章浏览阅读136次。decoration: TextDecoration.lineThrough, decorationColor: Colors.black, //solid:实线,double:双线,dotted:点虚线,dashed:横虚线,wavy:波浪线decorationStyle:TextDecorationStyle.wavy),);}class TextApp extends StatelessWidget {@overrideWidgetbuild(Bui..._flutter widget进阶
文章浏览阅读1.1w次,点赞14次,收藏17次。npm ERR! code ERR_SOCKET_TIMEOUTnpm ERR! network Socket timeoutnpm ERR! network This is a problem related to network connectivity.npm ERR! network In most cases you are behind a proxy or have bad network settings.npm ERR! network npm ERR! network If y_err_socket_timeout
文章浏览阅读3.7k次,点赞3次,收藏3次。表类型也叫做嵌套表。使用记录类型变量只能保存一行数据,这限制了SELECT语句的返回行数,如果SELECT语句返回多行就会错。Oracle提供了另外一种自定义类型,也就是表类型,它是对记录类型的扩展,允许处理多行数据,类似于表。创建表类型的语法如下:TYPE table_name AS | IS TABLE OF data_type [ NOT NULL ];语法说明如下:..._oracle表类型不能接收多行数据
文章浏览阅读4.6k次。C# Winform通用开发框架,可用于各种定制软件开发(赠 全部源码)。框架自带标签打印、自动更新、多语言等功能。_winform框架源码
文章浏览阅读510次。上图问题描述:今天突然发现页面点击返回时候,整体内容下移,准确的说是:返回过程中,页面会出现整体往右下角移动,而不是直接向右移动出现原因:我这边的原因,是因为点击了输入框,然后返回的时候,键盘退下导致整体页面下移!- (void)actionBack { [self.view endEditing:YES]; [super actionBack];}索性我就在返回方法前,添加了默认退出键盘方法解决总结:此处是因为返回过程中,有一个下移动画和返回动画一起所导致的后记:上诉只_ios 弹出键盘 返回界面下移
文章浏览阅读2.2w次,点赞11次,收藏73次。在Windows操作系统上安装和卸载软件是常见的操作。然而,仅仅通过常规的卸载过程并不能完全清除软件的所有残留数据。为了彻底卸载软件并清理相关的残留数据,我们需要采取额外的步骤。本文将详细介绍在Windows上彻底卸载软件以及清理残留数据的步骤。_windows可以彻底卸载软件的