1. HttpServletRequest

 

[Controller]

@RequestMapping(value="/sendTest", method=RequestMethod.POST)
    public String HttpServletRequestTest(HttpServletRequest req) {
        System.out.println("== HttpServletRequest Test ==");
        System.out.println(req.getParameter("id"));
        System.out.println(req.getParameter("pw"));
        return "view/main";
    }

 

[html]

<form action="/sendTest" method="post">
    <input type="text" name="id"/>
    <input type="password" name="pw"/>
    <input type="submit" value="send"/>
</form>

 

 

 

2. Map

 

[Controller]

@RequestMapping(value="/sendTest", method=RequestMethod.POST)
public String getMap(@RequestParam Map<String, Object> map) {
    System.out.println("== Map Test ==");
    System.out.println(map.get("id"));
    System.out.println(map.get("pw"));
    return "view/main";
}

 

[html]

<form action="/sendTest" method="post">
    <input type="text" name="id"/>
    <input type="password" name="pw"/>
    <input type="submit" value="send"/>
</form>

 

 

3. VO(Entity)

 

[VO]

@Entity
@Getter
@Setter
@Table(name ="member")
public class Member {
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private String id;
    private String password1;
}

 

[Controller]

@RequestMapping(value="sendTest", method=RequestMethod.POST)
public String getVO(Member vo) {
    System.out.println("== VO(Entity) Test ==");
    System.out.println(vo.getId());
    System.out.println(vo.getPassword1());
    return "view/main";
}

 

[html]

<form action="/sendTest" method="post">
    <input type="text" name="id"/>
    <input type="password" name="password1"/>
    <input type="submit" value="send"/>
</form>

 

4. arrayList (수정하기!!!)

 

[Controller]

@RequestMapping(value="sendTest", method=RequestMethod.POST)
public String ArrayListTest(@RequestParam ArrayList<String> array) {
    System.out.println("== ArrayList Test==");
    for(int i=0, n=array.size(); i<n; i++) {
        System.out.println(array.get(i));
    }
    return "view/main";
}

 

[html]

<form action="/sendTest" method="post">
    <input type="text" name="array"/>
    <input type="password" name="array"/>
    <input type="submit" value="send"/>
</form>

 

 

 

 


+ Recent posts