AdSense

顯示具有 spring-mvc 標籤的文章。 顯示所有文章
顯示具有 spring-mvc 標籤的文章。 顯示所有文章

2025/3/23

SpringMVC WebLogic org.xml.sax.SAXParseException: Content is not allowed in prolog

SpringMVC網路應用程式部屬到WebLogic伺服器時出現org.xml.sax.SAXParseException: Content is not allowed in prolog錯誤的解法如下。

2024/12/16

Spring MVC 當Controller層已驗證過外部傳入的資料,Service層是否還要再驗證從Controller傳入的參數?

此篇為2019年想寫的草稿



要!永遠不要信任傳入的參數是被驗證過的,因此總是去驗證傳入參數。但實務上可能因為進度、偷懶或是沒特別要求,所以不會特別額外驗證。

2021/8/30

Spring Boot REST API使用ResponseEntity返回自訂的HTTP status及Content-Type

Spring Boot在Controller或ControllerAdvice可使用ResponseEntity<T>自訂回應(Reesponse)返回的HTTP狀態碼及Content-Type如下。

2021/6/11

Spring Boot Web MVC REST API 下載檔案 download file

Spring Boot Web在提供REST API下載的連結方式如下。

2021/5/28

Spring Boot Thymeleaf TODOLIST 範例

使用Spring Boot Thymeleaf搭建TODOLIST應用程式範例。

2021/4/15

Spring MVC @RequestParam 取得url參數

Spring MVC在Controller @RequestMapping method可用@RequestParam接收url參數。

2021/2/4

Spring Boot 重新導向新網址 redirect url

Spring Boot 重新導向到別的網址的方式如下。

2021/1/12

Spring Web @RequestMapping optional @PathVariable API

Spring Web在Controller使用@RequestMapping設定API路徑時可選擇是否填入路徑參數(path variable)的作法如下。

2020/12/25

Spring Boot Web @ResponseBody 作用

Spring Boot Web (Spring MVC)的@ResponseBody作用如下。

Spring Boot Web @RestControllerAdvice與@ControllerAdvice區別

Spring Boot Web專案統一處理Controller拋出的例外錯誤可用@ControllerAdvice或@RestControllerAdvice,兩者區別如下。

2020/7/31

Spring Boot 使用ResponseBodyAdvice修改Response

在Spring Boot Web (Spring Web MVC)修改API回應內容,也就是response body的作法如下。

2020/6/13

Spring Web 處理存取資料庫例外錯誤 handle database access exception

在Spring Web專案中,通常在DAO或Repository層存取資料庫,而存取資料庫時拋出例外錯誤該在哪處理?

2020/4/10

2019/12/24

Spring Boot @ControllerAdvice return json response

在Spring Boot / Spring Web MVC的@ControllerAdvice類別處理錯誤時,如果要以json返回結果,可使用ResponseEntity<T>回傳。

2019/12/23

Spring Boot @ControllerAdvice用法

本篇介紹Spring Boot/Spring Web MVC的@ControllerAdvice annotation的用法。

2019/11/5

Spring Boot Request method 'POST' not supported

今天使用Postman送出POST請求呼叫API時,console印出Request method 'POST' not supported訊息而無法正確呼叫。

2019/9/24

Spring MVC 修改request參數為 UTF-8 編碼

Spring MVC 修改request參數編碼為UTF-8的方法如下。

2019/8/24

Spring Boot 設定 Interceptor 攔截器範例

本篇介紹如何在Spring Boot應用程式中設定Inteceptor攔截器,其可攔截傳入Controller的Request及攔截從Controller回傳給Client的Response。

2019/5/14

AdSense