1. HTML
1. form의 target과 2. iframe의 name에 동일한 이름을 입력하고, form을 submit 합니다.
<html>
<body>
<form
id="PayForm"
target="PayForm"
action="http://localhost:8080/api/v1/pay/form"
method="post">
<input
type="hidden"
name="UserName"
value="HelloWorld"
/>
</form>
<!-- form의 target과 iframe의 name에 동일한 이름을 적어줍니다. -->
<iframe
name="PayForm"
width="300"
height="300">
</iframe>
<script>
document.querySelector("#PayForm").submit()
</script>
</body>
</html>
2. Server
package com.example.vuespringbootinicis.pay.controller;
import org.springframework.web.bind.annotation.*;
@RequestMapping("/api/v1/pay")
@RestController
public class PayController {
@PostMapping("/form")
public String PayRequest(@RequestBody String UserName) {
System.out.println("UserName !!! " + UserName);
return "pay";
}
}
3. 확인
1) server
2) html