http://localhost:8081/hoho/userInfo?id=this&name=aaaa&tel=010&email=this@daum.net
@Controller
public class HomeController {
// @Autowired
// Command command;
@RequestMapping("userInfo")
public String userInfo(User user){
Command command = new Command();
command.getInfo(user);
return "userInfo";
}
}
package com.spring.hoho;
public class User {
private String id;
private String name;
private String tel;
private String email;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
package com.spring.hoho;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
public class Command {
@Autowired
User user;
public void getInfo(User user){
//user = new User();
String id = user.getId();
String name = user.getName();
String tel = user.getTel();
String email = user.getEmail();
System.out.println("id: "+id);
System.out.println("name: "+name);
System.out.println("tel: "+tel);
System.out.println("email: "+email);
}
}
'기존카테고리 > Spring Tip' 카테고리의 다른 글
@RequestMapping void, String, ModelAndView 차이 (0) | 2017.07.25 |
---|---|
pom.xml 설정시 참고 사이트 MVNRepository.com (0) | 2017.07.25 |
CGLIB 라이브러리 설치 (0) | 2017.07.24 |
Spring 파라미터 값 전달 예제 2 (0) | 2017.07.21 |