-먼저 struts2_ajax라는  Tomcat 프로젝트 작성
-Commons-logging, freemarker, ognl, struts2-core, xwork, log4j 라이브러리를 적절히 추가
-[web.xml]
 




<?xml version="1.0" encoding="UTF-8"?>


<web-app id="WebApp_9" version="2.4"


          xmlns="http://java.sun.com/xml/ns/j2ee"


          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"


          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee


                              http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">



    <display-name>Struts2 HelloWorld</display-name>



    <filter>


        <filter-name>struts2</filter-name>


        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>


    </filter>



    <filter-mapping>


    <filter-name>struts2</filter-name>


    <url-pattern>/*</url-pattern>


    </filter-mapping>


</web-app>



[/ajax.js]
var AutoComplete = {
        xmlHttp : null,
        /* XMLHttp객체생성/
        getXMLHttpRequest: function() {
if(window.ActiveXObject){//인터넷 익스플로러일 경우
                          try{  return new ActiveXObject("Msxml2.XMLHTTP");
                          }catch(e){
                                  try{
                                          return new ActiveXObject("Microsoft.XMLHTTP");
                                   }catch(e1){
                                           return null;
                                }
                        }
                }
                 //다른 브라우저일 경우
                else if(window.XMLHttpRequest){   return new XMLHttpRequest();         }
                //브라우저 식별 실패
                 else{                         return null;                }
        },


         /* XMLHttp Request를 서버로 */
        ContentLoader: function(url, execFunction) {
                 xmlHttp = this.getXMLHttpRequest();
                 xmlHttp.onreadystatechange = execFunction;
                 xmlHttp.open("POST", url, true); // url의 주소를 GET방식으로 열 준비를 한다.
                xmlHttp.send(); //서버에 전송한다.
        },
        /* XMLHttp Response가 서버로 부터 온전한 상태로 왔는지 확인   */
        getState: function() {
                if(xmlHttp.readyState == 4){ //데이터의 전부를 받은 상태
                        if(xmlHttp.status == 200){//요청 성공
                                   return true;
                          }else{
                                  return false;
                        }
                }
        }
} 


 

 

 

 

'자바 > JAVA...Spring' 카테고리의 다른 글

Spring 3.2 & MyBatis] 날짜형 바인드 (컨트롤러 작성(2))  (0) 2015.12.22
Spring 3.2 & MyBatis] 날짜형 바인드 (컨트롤러 작성(1))  (0) 2015.12.22
CSV ??  (0) 2015.12.22
innerHTML이란?  (0) 2015.12.22
simpleResponse.xml  (0) 2015.12.21

+ Recent posts