Browser와 WAS가 있어야 Remote Program을 call할 수 있다.
package com.iming.log01;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller //program register
public class Hello {
@RequestMapping("/hello") //url과 program mapping
public void main() {
System.out.println("Hello");
}
}
ex)
Server Address: http://www.iming.com
WAS(Tomcat) port: 8080
Context Root: log01
http://www.iming.com:8080/log01/hello로 remote program call
mapping url로 call하므로 method name은 별도이다.
main method는 instance method, Tomcat이 object로 생성.
main method는 static이어도 상관이 없으나, static method는
instance member를 쓸 수 없다. instance method로 사용하는
것이 유리하다.
method가 private이어도, remote call mapping을 해서 call은 가능하나
class 내부에서는 여전히 private이다. Spring에서 이것을 가능하게 하는 것은
Reflection API(java.lang.reflect)를 사용하기 때문이다.