본문 바로가기
비트 장기/jsp

8/18 복습17일꺼 보충 mvc넘어가는거 알기

by woohyun22 2018. 8. 19.

index-i


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*, java.text.*"%>
 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<head>
<title>메인 페이지</title>
</head>
<body>
    <%=new Date()%>
    <h2>Hello World</h2>
    <a href="t1">링크1</a>
    <a href="t3">링크3</a>
    <a href="t4?nickname=apple">링크4</a>
    <a href="t5?nickname=apple&salary=300">링크5</a>
    <a href="t6?nickname=apple1&salary=400">링크6</a>
</body>
cs



java -c


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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package Pack01;
 
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
 
@Controller
public class Tiger {//class와 controller사이는 붙여서 써야된다.
    @RequestMapping("t1")
    String func01() {//t1이라는 id로 이 func01이라는 함수를 콜하시오
        System.out.println("들어왔음");
        return null;
    }
    //i->c  index->java
    @RequestMapping("t3")
    String func03() {
        System.out.println("들어왔음");
        return "LionView";
    }
    //i->c->v  index->java->view
    @RequestMapping("t4")
    //String func04(String nickname) {
        //String func04(@ReqestParam(value = "nickname") String nickname)
        String func04(@RequestParam(value = "nickname") String s)
        {//던질때는 nickname이 던졌다. 받은 후에는 s가 가지고 있어라.
        //System.out.println(nickname);
        System.out.println(s);
        return "LionView";
    }
    //i->c->v index-(@requestparam)>java->view
    @RequestMapping("t5")
    //String func05(String nickname, int salary) {
    String func05(
            @RequestParam(value = "nickname")String s,
            @RequestParam(value = "salary")int n
            ) {
        //System.out.println(nickname+salary);
        System.out.println(s+n);
        return "LionView";
    }
    @RequestMapping("t6")
    String func06(Model model, String nickname, int salary) {
        //model.addAttribute("", nickname);
        //""문자열을 나타냄 앞의 인수는 인식id 뒤는 받는값.
        //model.addAttribute(nickname, nickname);
        model.addAttribute("k1", "dog");
        model.addAttribute("salary", salary);
        return "LionView";
        //model을 사용하면 console엔 뜨지않는다.model객체를 넘긴다.
//LionView에서 ${k1}적으면 웹상에 출력가능
    }
}
 
cs


뷰는 아직 그대로


728x90

'비트 장기 > jsp' 카테고리의 다른 글

8/18 mvc  (0) 2018.08.18
8/17 jsp 복습  (0) 2018.08.18
8/16 (out,)  (0) 2018.08.16
8/14 복습(count쓰는법? rs.next())  (0) 2018.08.16
8/13 복습  (0) 2018.08.14

댓글