Skip to content

Instantly share code, notes, and snippets.

@albert-hg
albert-hg / pom.xml
Last active July 28, 2020 07:32
the basic structure for pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<!-- 專案的名稱、描述、版本等專案基本資訊 -->
<groupId></groupId>
<artifactId></artifactId>
<version></version>
@albert-hg
albert-hg / pom.xml
Created July 31, 2020 04:25
introduction to the basic structure for the plugins
<?xml version="1.0" encoding="UTF-8"?>
<project>
<!-- 被執行於build階段的plugins會配置於此 -->
<build>
<!-- 實際執行的plugins會配置於此 -->
<plugins>
...
</plugins>
@albert-hg
albert-hg / HomePage.java
Last active August 5, 2020 03:56
show the basic java servlet structure
import javax.servlet.*;
import javax.servlet.http.*;
public class HomePage extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE html>");
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head></head>
<body>
<div> This is home page. <div>
<div> Login: <%= request.getSession()%> <div>
</body>
</html>
@albert-hg
albert-hg / web.xml
Created August 5, 2020 03:44
mapping servlet and jsp by web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet-mapping>
<servlet-name>HomePage</servlet-name>
<url-pattern>/HomePage</url-pattern>
</servlet-mapping>
</web-app>
package com.albert.management;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ManagementApplication {
public static void main( String[] args ) {
SpringApplication.run(ManagementApplication.class, args);
}
public ConfigurableApplicationContext run(String... args) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
ConfigurableApplicationContext context = null;
Collection<SpringBootExceptionReporter> exceptionReporters = new ArrayList<>();
// 1. 設定系統的 Property
configureHeadlessProperty();
// 2. 初始化 Listener
server:
port: 8080