반응형
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- KAFKA
- spring boot redis
- coalesce
- ChannelPipeline
- netflix oss
- JPA
- WebLogic
- mybatis
- Airflow
- vue.js
- Spring Open Feign
- spring cloud
- weblogic 10
- Netty
- Docker Compose
- Hibernate
- argo cd
- docker compose mysql
- redis
- spring boot
- RabbitMQ
- Selenium
- docker
- jmeter
- grafana
- Redis Sentinel
- MySQL
- cassandra
- QueryDSL
- docker-compose
Archives
- Today
- Total
IT.FARMER
redirect / forward Parameter 전체 본문
반응형
가끔 전체 적인 parameter를 redirect 파라미터로 보내고 싶은경우가 있다.
이런경우엔 코드가 잘못됬다고 볼수도 있지만. 급한? 처리를 해야할때...
RedirectAttributes에 모두 담아 보내버리자.
Map<String, Object> attributes = new HashMap<>();
Enumeration<?> params = request.getParameterNames();
while (params.hasMoreElements()){
String name = (String)params.nextElement();
attributes.put(name, request.getParameter(name));
}
redirectAttributes.addAllAttributes(attributes);
redirectAttributes.addAttribute("reservationMngNo", reservationHistory.getReservationMngNo());
return "redirect:/admin/cashReceipt/requestCashReceipt";
위 경우엔 기본 request parameter와 추가된 parameter를 같이 보낼수 있다.
있는 그대로 보내고 싶은경우
RequestDispatcher dispatcher = request.getRequestDispatcher("/admin/cashReceipt/requestCashReceipt");
dispatcher.forward(request, response);
request.getParameterMap()에 강제로 추가 하고 싶었으나, HTTP 정책에 의해 추가불가능한 MAP구조라(변경불가) 다음과 같이 추가해서 보내는것은 불가능하다.
String[] values = {reservationHistory.getReservationMngNo().toString()};
request.getParameterMap().put("reservationMngNo", values);
결론
RedirectAttributes 에 ReqiestParameter 하나식 열거 하여 추가한다.
반응형
'Spring' 카테고리의 다른 글
ehcache attribute (0) | 2017.07.11 |
---|---|
Spring redirect POST 전송 RedirectAttributes Parameter (0) | 2017.05.31 |
Spring Boot hot swapping(springloaded debuging) 방법 (0) | 2016.09.01 |
Spring Transaction is already completed - do not call commit or rollback more than once per transaction (0) | 2016.03.07 |
Spring Transaction 선언적 트랜잭션(AOP) , 메소드에서 직접 실행(DefaultTransactionDefinition) (0) | 2016.03.03 |