Creating a dynamic web page using Spring internalizr (Gradle), IntelliJ, and AWS EC2 - Step 4 XXS prevention, writing test code
1. Avoid XXS
Change and save the textarea value to prevent script attacks. In the case of the existing popol, the textarea is at the mail transmission end, and to set this part, security is processed when the mail sending button is pressed.
2. Write JUnit test code
I wrote test code for the email sending part. Although it is an extension of stage 3, it was written in stage 4 considering it as a maintenance and repair section.
As a result, when all tests are completed, you can see that the mail is sent as set as follows.
+ Resolving errors
When running the test, the email was sent well, but a failure message appeared while executing the Controller method of the original code.
Looking at the content, it appears that NullPointer has occurred. I thought it was because of the part where parameter values were received in the existing method (there was a ModelAndView among the parameter values, but it was not received properly).
This was solved by setting the initial value of ModelAndView to new ModelAndView to prevent Nulls from occurring.
| 24. Spring - Thymeleaf 템플릿 메일발송
| Spring Boot 메일전송 : Spring Boot 2, Mail, Thymelef
| [Java - 기능 - (14) ] ModelAndView 서블릿
Comments
No comments yet. Be the first!
164 posts in 테크
- 2233D Gaussian Splatting vs Unreal Engine: Two Ways to Build a 3D World — and Where Each One Ships
- 222LLMs Inside Unreal Engine: The New Skills Game Developers Need in 2026
- 220Living With Claude Fable 5: How the Most Capable Model Changes the Way You Actually Work
- 219Luma's Bet: From Video Generator to a Single Model That Thinks in Pixels
- 215The Best AI Video Models in 2026: Types, Differences, and Where This Is All Going