작성
·
246
1
test/100/200/300 실행시에..
콘솔창에 값은 잘 출력이 되는데요... result.jsp 경로가 이상하게 나옵니다..(그 전까지는 잘 나왔구요...)
에러:메시지 파일 [/test5/100/200/WEB-INF/views/result.jsp]을(를) 찾을 수 없습니다.
<==경로가 왜 이렇게 바뀌는지요??? ...
1. index.jsp
<a href="test5/100/200/300">test5</a>
2. TestController
@GetMapping("/test5/{data1}/{data2}/{data3}")
public String test5(@PathVariable int data1,
@PathVariable int data2,
@PathVariable int data3) {
System.out.println("data1 : " + data1);
System.out.println("data2 : " + data2);
System.out.println("data3 : " + data3);
return "result";
}
------------------------------------------------
이 전까지는 모든 예제 잘 출력되었구요.....
아시는 분은 답변 주시면 감사하겠습니다;;;;
답변 4
0
0
0
package kr.hs.study.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.WebRequest;
@Controller
public class TestController {
@GetMapping("/")
public String index() {
return "index";
}
@GetMapping("/test1")
public String test1() {
return "result";
}
@GetMapping("/test2")
public String test2(HttpServletRequest request) {
String data1=request.getParameter("data1");
String data2=request.getParameter("data2");
String [] data3=request.getParameterValues("data3");
for(String str : data3) {
System.out.println("data3:"+str);
}
System.out.println("data1:"+data1);
System.out.println("data2:"+data2);
return "result";
}
@PostMapping("/test3")
public String test3(HttpServletRequest request) {
String data1=request.getParameter("data1");
String data2=request.getParameter("data2");
String [] data3=request.getParameterValues("data3");
if(data3 !=null) {
for(String str : data3) {
System.out.println("data3:"+str);
}
}
System.out.println("data1:"+data1);
System.out.println("data2:"+data2);
return "result";
}
@GetMapping("/test4")
public String test4(WebRequest request) {
String data1=request.getParameter("data1");
String data2=request.getParameter("data2");
String [] data3=request.getParameterValues("data3");
for(String str : data3) {
System.out.println("data3:"+str);
}
System.out.println("data1:"+data1);
System.out.println("data2:"+data2);
return "result";
}
@GetMapping("/test5/{data1}/{data2}/{data3}")
public String test5(@PathVariable int data1,
@PathVariable int data2,
@PathVariable int data3) {
System.out.println("data1 : " + data1);
System.out.println("data2 : " + data2);
System.out.println("data3 : " + data3);
int add=data1+data2+data3;
System.out.println("add:"+add);
return "result";
}
@GetMapping("/test6")
public String test3(@RequestParam(defaultValue="2") int data1,
@RequestParam int data2,
@RequestParam int [] data3) {
if(data3 !=null) {
for(int str : data3) {
System.out.println("data3:"+str);
}
}
System.out.println("data1:"+data1);
System.out.println("data2:"+data2);
return "result";
}
@GetMapping("/test7")
public String test7(@RequestParam(value="data1") int value1,
@RequestParam(value="data2") int value2,
@RequestParam(value="data3") int [] value3) {
if(value3 !=null) {
for(int str : value3) {
System.out.println("data3:"+str);
}
}
System.out.println("data1:"+value1);
System.out.println("data2:"+value2);
return "result";
}
}
입니다...
감사합니다..
0