https://www.omnibuscode.com/zeroboard/zboard.php?id=seeyou_programing_javascript&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=headnum&desc=asc&no=38원본 소스 및 자세한 설명은 링크#1에서...
1. Test HTML
2. Spring Controller
1. Test HTML
·미리보기 | 소스복사·
- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
- >
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Insert title here< span>title>
- <script src="http://localhost:8080/pms/js/prototype/prototype.js" type="text/javascript">< span>script>
- <script language="javascript">
- function ajaxRequest(strResponseURL){
- var httpObj = new Ajax.Request (
- strResponseURL, {
- parameters:Form.serialize('frm'),
- //onSuccess:displayJson, // 성공했을 경우, displayJson 함수 호출
- onSuccess:displayTextHtml, // 일반 텍스트나 html 형식을 경우
- onFailure:displayError // 실패 했을 경우, displayError 함수 호출
- }
- );
- }
- function displayJson(responseHttpObj) {
- var returnData = responseHttpObj.responseText; // 만약 XML 형태로 데이터를 받아온다면 responseHttpObj.responseXML
- returnData = eval("(" + returnData + ")");
- switch (returnData.dataType) {
- // 사실 응답 페이지가 utf-8로 저장되었다면 decodeURIComponent를 안써도 상관없지만, 그래도 혹시나 하여 사용
- case 'one' : $("results").innerHTML = decodeURIComponent(returnData.response);
- break;
- case 'array' : viewResponse(returnData.response);
- break;
- default : $("results").innerHTML = decodeURIComponent(returnData);
- }
- }
- function displayTextHtml(responseHttpObj) {
- var returnData = responseHttpObj.responseText;
- $("results").innerHTML = decodeURIComponent(returnData);
- }
- function displayError() {
- $("results").innerHTML = 'AJAX failed';
- }
- function viewResponse(data) {
- var intLength = data.length;
- var strHTML = "";
- for(var i=0; i<intLength; i++) {
- strUserID = decodeURIComponent(data[i].userID);
- strUserName = decodeURIComponent(data[i].userName);
- strHTML += "ID : " + strUserID + '<br>';
- strHTML += "이름 : " + strUserName + '<br>';
- }
- $("results").innerHTML = strHTML;
- }
- < span>script>
- < span>head>
- <body>
- <h3>AJAX in prototype.js Example< span>h3>
- <form id="frm">
- <p><input type="button" value=" 확인 " onclick="ajaxRequest('sso/userAction.do');">< span>p>
- < span>form>
- <div id="results">[Results Area]< span>div>
- < span>body>
- < span>html>
2. Spring Controller
·미리보기 | 소스복사·
- import java.io.PrintWriter;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.springframework.web.servlet.ModelAndView;
- import org.springframework.web.servlet.mvc.Controller;
- import com.seeyouservice.pms.common.TestStaticField;
- public class UserAction implements Controller {
- public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
- PrintWriter out = response.getWriter();
- if(TestStaticField.TESTACCOUNT != null) {
- out.println(TestStaticField.TESTACCOUNT.getUserid());
- } else {
- out.println("nobody");
- }
- out.close();
- return null;
- }
- }
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 81 | [React.JS] 강좌 목록 | 황제낙엽 | 2020.05.19 | 385 |
| 80 |
Redux: React 앱의 효율적인 데이터 교류
| 황제낙엽 | 2020.05.19 | 971 |
| 79 | Jasmine 관련 | 황제낙엽 | 2020.01.13 | 492 |
| 78 | 마우스 드래그(drag)시 iframe 위에서 컨트롤 잃는 현상과 해결 방안 | 황제낙엽 | 2017.12.12 | 28271 |
| 77 | 다섯 가지의 Ajax 우수 사례 | 황제낙엽 | 2011.04.07 | 490 |
| 76 | 15+ jQuery Popup Modal Dialog Plugins and Tutorials | 황제낙엽 | 2011.03.30 | 574 |
| 75 |
$.ajax() 공략
| 황제낙엽 | 2011.03.27 | 670 |
| 74 | DWR을 이용해서 객체를 JSON으로 변환하기 | 황제낙엽 | 2011.03.25 | 347 |
| 73 |
json을 이용한 로그인 구현
| 황제낙엽 | 2011.03.25 | 832 |
| 72 | How Prototype extends the DOM (Prototype으로 DOM을 확장하는 법) | 황제낙엽 | 2011.03.24 | 695 |
| 71 | 스크랩 | 황제낙엽 | 2009.04.16 | 439 |
| 70 | YUI 스크랩 | 황제낙엽 | 2009.03.12 | 323 |
| 69 | 스크랩 | 황제낙엽 | 2009.03.11 | 316 |
| 68 | 관심 사이트 | 황제낙엽 | 2009.03.12 | 431 |
| 67 | 웹 개발 패러다임의 전환 - Flex와 Ajax의 동거 | 황제낙엽 | 2006.12.21 | 434 |
| 66 | Ajax 강의 정리 | 황제낙엽 | 2006.04.04 | 387 |
| 65 | 자바 기술을 이용한 AJAX의 활용 | 황제낙엽 | 2006.02.08 | 347 |
| 64 |
대표적인 AJAX Framework 소개
| 황제낙엽 | 2007.02.14 | 414 |
| 63 | Ajax Framework 인기 순위: Ajaxian.com | 황제낙엽 | 2007.02.13 | 368 |
| 62 |
prototype.js 를 위한 개발자 노트 (Ajax Framework)
| 황제낙엽 | 2007.02.15 | 335 |