List

수요일, 12월 16, 2015

getRealPath 알아보는법


  • 컨트롤러에서만 실행
    • main 폴더의 주소를 출력 하는법

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class PTCtrl implements ApplicationContextAware{
    
    private WebApplicationContext context = null;
    
    @RequestMapping(params="method=list")
    public String form01(Model d){// list page
        String path=context.getServletContext().getRealPath("main");
        
                System.out.println(path);
                System.out.println(path);
                System.out.println(path);
                System.out.println(path);
                System.out.println(path);
    
        return "personalTraining/ListPage";
    }
cs


  • 결과

1
2
3
4
5
6
C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\finalproject\main
C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\finalproject\main
C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\finalproject\main
C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\finalproject\main
C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\finalproject\main
cs

s

댓글 없음:

댓글 쓰기