1. dwr 다운로드
http://directwebremoting.org/dwr/download.html
2. WAS WEB-INF/lib/ 에 라이브러리를 추가하고
3. web.xml 에 dwr servlet 을 추가한다.
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
4. dwr.xml 을 WEB-INF/ 에 생성한다.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" "http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
<allow>
<create creator="new" javascript="DwrSvc" >
<param name="class" value="package.DwrSvc"/>
<include method="update"/>
</create>
</allow>
</dwr>
5. http://localhost:8080/dwr/ 확인한다.
6. jsp에서 자바스크립트 넣는다.
<script type='text/javascript' src='/vs/dwr/interface/DwrSvc.js'></script>
<script type='text/javascript' src='/vs/dwr/engine.js'></script>
<script type='text/javascript' src='/vs/dwr/util.js'></script>
7. 실제 자바스크립트에서 호출한다.
<script type='text/javascript'>
function dwrGo(param){
DwrSvc.update(param, rsFunction);
}
function rsFunction(rsdata){
alert(rsdata);
}
'Ajax' 카테고리의 다른 글
Reverse Ajax with DWR (0) | 2010.09.28 |
---|