JqGrid Ajax 데이터 불러오기
프로그래밍/Grid 공통2018. 2. 13. 11:03
datatype : 'local' 로 설정후에 ajax 를 실행하면 데이터를 불러온다
'프로그래밍 > Grid 공통' 카테고리의 다른 글
JqGrid Json 데이터 불러오기 (0) | 2018.02.12 |
---|
JqGrid Json 데이터 불러오기
프로그래밍/Grid 공통2018. 2. 12. 15:42
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | @RequestMapping (value = "/test6.do" , method = RequestMethod.POST) @ResponseBody public String test6(){ JSONObject jsonObject = new JSONObject(); JSONArray listData = new JSONArray(); JSONObject listInfo = new JSONObject(); // 정보 입력 listInfo.put( "SEQ" , "송강호" ); listInfo.put( "TITLE" , "남자" ); listInfo.put( "INSERT_TIME" , "25" ); listInfo.put( "INSERT_ID" , "남궁민수" ); listInfo.put( "READ_COUNT" , "1" ); // Array에 입력 listData.add(listInfo); listInfo = new JSONObject(); listInfo.put( "SEQ" , "송강호" ); listInfo.put( "TITLE" , "남자" ); listInfo.put( "INSERT_TIME" , "25" ); listInfo.put( "INSERT_ID" , "남궁민수" ); listInfo.put( "READ_COUNT" , "1" ); listData.add(listInfo); // 전체의 JSONObject에 사람이란 name으로 JSON의 정보로 구성된 Array의 value를 입력 jsonObject.put( "page" , "1" ); jsonObject.put( "total" , "2" ); jsonObject.put( "listData" , listData); String jsonInfo = jsonObject.toString(); System.out.println( "jsonInfo:" + jsonInfo); return jsonInfo; } <p style= "FLOAT: none; TEXT-ALIGN: center; CLEAR: none" > </p><p> </p> |
'프로그래밍 > Grid 공통' 카테고리의 다른 글
JqGrid Ajax 데이터 불러오기 (0) | 2018.02.13 |
---|
Ajax JSON 데이터 주고 받기
프로그래밍/Spring2018. 1. 31. 13:56
1 2 3 4 5 6 7 8 9 10 11 12 13 | <form id= "fm" name= "fm" method= "post" > <input type= "hidden" name= "userId" id= "userId" value= "test1234" > <input type= "hidden" name= "userPass" id= "userPass" value= "pass1234" > 축구:<input type= "checkbox" name= "type" id= "type" value= "축구" > 야구:<input type= "checkbox" name= "type" id= "type" value= "야구" > 농구:<input type= "checkbox" name= "type" id= "type" value= "농구" > </form> <button onclick= "goAjax1();" >goAjax1</button> <button onclick= "goAjax2();" >goAjax2</button> <button onclick= "goAjax3();" >goAjax3</button> <button onclick= "goAjax4();" >goAjax4</button> <button onclick= "goAjax5();" >goAjax5</button> <button onclick= "goAjax6();" >goAjax6</button> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | function goAjax6(){ var checkValues = new Array(); $( "input[name='type']:checked" ).each( function (){ checkValues.push($( this ).val()); }); var data = { "userId" : $( "#userId" ).val(), "userPass" :$( "#userPass" ).val(), "type" :checkValues }; $.ajax({ type: "POST" , url : "<c:url value=" /goAjax6. do ">" , data : JSON.stringify(data), dataType: "json" , contentType: "application/json;charset=UTF-8" , async: false , success : function (data, status, xhr) { console.log(data); }, error: function (jqXHR, textStatus, errorThrown) { alert( "error= " + errorThrown); } }); } </c:url> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /** * @param JSON 데이터 받기 * @return * @throws Exception */ @RequestMapping (value = "/goAjax6.do" , method = RequestMethod.POST) @ResponseBody public Map<string, object= "" > goAjax3( @RequestBody String param) throws Exception{ JSONObject json = JSONObject.fromObject(param); System.out.println( "userId:" +json.get( "userId" )); System.out.println( "userPass:" +json.get( "userPass" )); System.out.println( "type:" +json.get( "type" )); JSONArray array = (JSONArray) json.get( "type" ); for ( int i= 0 ; i<array.size(); i++){= "" system.out.println( "array:" +array.get(i));= "" }= "" map<string,= "" object= "" > map = new HashMap<string, object= "" >(); map.put( "AA" , "1" ); map.put( "BB" , "2" ); return map; } </string,></array.size();></string,> |
'프로그래밍 > Spring' 카테고리의 다른 글
Ajax JSON Map 타입으로 넘기고 받기 (0) | 2018.01.30 |
---|---|
전자정부 프레임워크 Ajax 설정 (0) | 2018.01.09 |
Spring properties 설정방법 (0) | 2017.10.26 |
Ajax JSON Map 타입으로 넘기고 받기
프로그래밍/Spring2018. 1. 30. 14:57
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | <form id= "fm" name= "fm" method= "post" > <input type= "hidden" name= "userId" id= "userId" value= "test1234" > <input type= "hidden" name= "userPass" id= "userPass" value= "pass1234" > 축구:<input type= "checkbox" name= "type" id= "type" value= "축구" > 야구:<input type= "checkbox" name= "type" id= "type" value= "야구" > 농구:<input type= "checkbox" name= "type" id= "type" value= "농구" > </form> <button onclick= "goAjax1();" >goAjax1</button> <button onclick= "goAjax2();" >goAjax2</button> <button onclick= "goAjax3();" >goAjax3</button> <button onclick= "goAjax4();" >goAjax4</button> <button onclick= "goAjax5();" >goAjax5</button> function goAjax5(){ var checkValues = new Array(); $( "input[name='type']:checked" ).each( function (){ checkValues.push($( this ).val()); }); var data = {}; data[ "userId" ] = $( "#userId" ).val(); data[ "userPass" ] = $( "#userPass" ).val(); data[ "type" ] = checkValues; $.ajax({ type: "POST" , url : "<c:url value=" /goAjax5. do ">" , data : JSON.stringify(data), dataType: "json" , contentType: "application/json;charset=UTF-8" , async: false , success : function (data, status, xhr) { console.log(data); }, error: function (jqXHR, textStatus, errorThrown) { alert( "error= " + errorThrown); } }); } @RequestMapping(value = "/goAjax5.do" , method = RequestMethod.POST) @ResponseBody public Map<string, object= "" > goAjax5(@RequestBody Map<string, object= "" > map) throws Exception{ System.out.println( "userId:" +map.get( "userId" )); System.out.println( "userPass:" +map.get( "userPass" )); System.out.println( "type:" +map.get( "type" )); Map<string, object= "" > resultMap = new HashMap<string, object= "" >(); map.put( "AA" , "1" ); return resultMap; } ##출력값 userId:test1234 userPass:pass1234 type:[축구, 야구, 농구] </string,></string,></string,></string,></c:url> |
'프로그래밍 > Spring' 카테고리의 다른 글
Ajax JSON 데이터 주고 받기 (0) | 2018.01.31 |
---|---|
전자정부 프레임워크 Ajax 설정 (0) | 2018.01.09 |
Spring properties 설정방법 (0) | 2017.10.26 |
전자정부 프레임워크 Ajax 설정
프로그래밍/Spring2018. 1. 9. 17:21
스프링 버전, 전자정부 프레임워크 버전 pom.xml 참고
- DispatcherServlet XML 설정파일
- Controller
또는
- DispatcherServlet XML 설정파일 - 꼭필요하다
- Controller
CASE3. @Controller 를 @RestController 으로 변경함 Spring 4.0은 @Controller와 @ResponseBody 을 합쳐놓은것 이상의 역할을 수행함
1 2 3 4 5 | < properties > < spring.maven.artifact.version >4.3.4.RELEASE</ spring.maven.artifact.version > < egovframework.rte.version >3.5.0</ egovframework.rte.version > < tiles.version >3.0.5</ tiles.version > </ properties > |
CASE1. josnView 를 이용하여 Ajax 설정방법
- pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 | < dependency > < groupid >net.sf.json-lib</ groupid > < artifactid >json-lib</ artifactid > < version >2.4</ version > < classifier >jdk15</ classifier > </ dependency > < dependency > < groupid >org.codehaus.jackson</ groupid > < artifactid >jackson-mapper-asl</ artifactid > < version >1.9.13</ version > </ dependency > |
1 2 3 4 5 | < bean id = "beanNameResolver" class = "org.springframework.web.servlet.view.BeanNameViewResolver" p:order = "0" > < bean id = "jsonView" class = "org.springframework.web.servlet.view.json.MappingJackson2JsonView" > < property name = "contentType" value = "application/json;charset=UTF-8" ></ property > </ bean > </ bean > |
1 2 3 4 5 6 7 | @RequestMapping (value = "/goAjax3.do" , method = RequestMethod.POST) public ModelAndView goAjax3() throws Exception{ ModelAndView mv = new ModelAndView( "jsonView" ); mv.addObject( "AA" , "1" ); mv.addObject( "BB" , "2" ); return mv; } |
CASE2. @ResponseBody 를 이용하여 Ajax 설정방법
- pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | < dependency > < groupid >com.fasterxml.jackson.core</ groupid > < artifactid >jackson-core</ artifactid > < version >2.8.8</ version > </ dependency > < dependency > < groupid >com.fasterxml.jackson.core</ groupid > < artifactid >jackson-annotations</ artifactid > < version >2.8.8</ version > </ dependency > < dependency > < groupid >com.fasterxml.jackson.core</ groupid > < artifactid >jackson-databind</ artifactid > < version >2.8.8</ version > </ dependency > |
1 2 3 4 5 | < dependency > < groupid >org.codehaus.jackson</ groupid > < artifactid >jackson-mapper-asl</ artifactid > < version >1.9.13</ version > </ dependency > |
1 | <!--?xml:namespace prefix = "mvc" /--> < mvc:annotation-driven ></ mvc:annotation-driven > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | @RequestMapping (value = "/goAjax1.do" , method = RequestMethod.POST) public @ResponseBody Map<string, object= "" > goAjax1() throws Exception { Map map = new HashMap<string, object= "" >(); map.put( "AA" , "1" ); map.put( "BB" , "2" ); map.put( "CC" , "3" ); map.put( "DD" , "4" ); return map; } @RequestMapping (value = "/goAjax2.do" , method = RequestMethod.POST) @ResponseBody public Map<string, object= "" > goAjax2() throws Exception{ Map map = new HashMap<string, object= "" >(); map.put( "AA" , "1" ); map.put( "BB" , "2" ); return map; } </string,></string,></string,></string,> |
'프로그래밍 > Spring' 카테고리의 다른 글
Ajax JSON 데이터 주고 받기 (0) | 2018.01.31 |
---|---|
Ajax JSON Map 타입으로 넘기고 받기 (0) | 2018.01.30 |
Spring properties 설정방법 (0) | 2017.10.26 |
웹서비스 테스트방법
프로그래밍/기타2017. 12. 21. 15:38
프로그램을 이용하여 톰캣 실행후 웹서비스 메서드 호출 테스트 할수 있음
Batch Class 별도로 log4j 파일 설정방법
프로그래밍/Java2017. 12. 21. 14:38
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | log4j.rootLogger=info, console log4j.logger.BatchCheck=info, BatchCheck log4j.logger.DB_BackUp=info, DB_BackUp # Direct log messages to stdout log4j.appender.console=org.apache.log4j.ConsoleAppender #log4j.appender.stdout.Target=System.out log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %5p (%C{ 2 } - %M:%L) - %m%n # Direct log message to log file log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.logfile.DatePattern= '.' yyyy-MM-dd log4j.appender.logfile.File=D:/work/magna/admin.log log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %5p (%C{ 2 } - %M:%L) - %m%n log4j.appender.logfile.Append= true # BatchCheck.java log4j.appender.BatchCheck=org.apache.log4j.DailyRollingFileAppender log4j.appender.BatchCheck.File=D:/work/magna/BatchCheck.log log4j.appender.BatchCheck.DatePattern= '.' yyyy-MM-dd log4j.appender.BatchCheck.Threshold=info log4j.appender.BatchCheck.layout=org.apache.log4j.PatternLayout log4j.appender.BatchCheck.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %5p (%C{ 2 } - %M:%L) - %m%n log4j.appender.BatchCheck.Append= true # IfTransferRequest.java log4j.appender.DB_BackUp=org.apache.log4j.DailyRollingFileAppender log4j.appender.DB_BackUp.File=D:/work/magna/DB_BackUp.log log4j.appender.DB_BackUp.DatePattern= '.' yyyy-MM-dd log4j.appender.DB_BackUp.Threshold=info log4j.appender.DB_BackUp.layout=org.apache.log4j.PatternLayout log4j.appender.DB_BackUp.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %5p (%C{ 2 } - %M:%L) - %m%n log4j.appender.DB_BackUp.Append= true |
1 2 3 4 | import org.apache.log4j.Logger; public class DB_BackUp { private final static Logger logger = Logger.getLogger( "DB_BackUp" ); } |
'프로그래밍 > Java' 카테고리의 다른 글
Map 데이터 출력방법 (0) | 2017.11.14 |
---|
Map 데이터 출력방법
프로그래밍/Java2017. 11. 14. 14:17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; public class MapUtil { public static void main(String[] args) { Map<integer, object= "" > map = new HashMap<integer, object= "" >(); map.put( 1 , "AAA" ); map.put( 2 , "BBB" ); map.put( 3 , "CCC" ); System.out.println( "\n ##### 방법1 #####" ); for ( int key : map.keySet()){ System.out.println( "key:" +key+ " value:" +map.get(key)); } System.out.println( "\n ##### 방법2 #####" ); for (Map.Entry<integer, object= "" > data : map.entrySet()){ System.out.println( "key:" +data.getKey()+ " value:" +data.getValue()); } System.out.println( "\n ##### 방법3 #####" ); Iterator<integer> iterater1 = map.keySet().iterator(); while (iterater1.hasNext()){ int key = iterater1.next(); System.out.println( "key:" +key+ " value:" +map.get(key)); } System.out.println( "\n ##### 방법4 #####" ); Set<integer> keySet = map.keySet(); Iterator<integer> iterator2 = keySet.iterator(); while (iterator2.hasNext()){ int key = iterator2.next(); System.out.println( "key:" +key+ " value:" +map.get(key)); } } } </integer></integer></integer></integer,></integer,></integer,> |
'프로그래밍 > Java' 카테고리의 다른 글
Batch Class 별도로 log4j 파일 설정방법 (0) | 2017.12.21 |
---|
[JavaScript] 클로저란
프로그래밍/JavaScript2017. 11. 1. 16:14
내부함수
자바스크립트는 함수 안에서 또 다른 함수를 선언할 수 있다.
함수 outter의 내부에는 함수 inner가 정의 되어 있다
클로저(closure)는 내부함수와 밀접한 관계를 가지고 있는 주제다.
1 2 3 4 5 6 7 8 9 10 11 12 | function outter(){ function inner(){ var name= 'closerTest' ; console.log(name); } inner(); } outter(); // closerTest가 출력된다. |
1 2 3 4 5 6 7 8 9 10 11 12 | function outter(){ var name= 'closerTest' ; function inner(){ console.log(name); } inner(); } outter(); // closerTest 가 출력된다. |
내부함수는 외부함수의 지역변수에 접근 할 수 있는데 외부함수의 실행이 끝나서 외부함수가
소멸된 이후에도 내부함수가 외부함수의 변수에 접근 할 수 있다. 이러한 메커니즘을 클로저라고 한다.
클로저란 내부함수가 외부함수의 지역변수에 접근 할 수 있고,
외부함수는 외부함수의 지역변수를 사용하는 내부함수가 소멸될 때까지 소멸되지 않는 특성을 의미한다.
1 2 3 4 5 6 7 8 9 10 11 | function outter(){ var name = 'closerTest' ; return function (){ alert(name); } } inner = outter(); inner(); // closerTest 가 출력된다. |
1개의 Tomacat 에서 프로젝트 2개 띄우기
Server/Tomcat2017. 11. 1. 09:24
tomcat/conf/server.xml 아래부분에 프로젝트 다르게 설정
1 2 3 4 5 6 7 8 | < engine name = "Catalina" defaulthost = "localhost" > < host name = "URL1" xmlnamespaceaware = "false" xmlvalidation = "false" autodeploy = "true" unpackwars = "true" appbase = "webapps" > < context path = "" docbase = "/usr/local/tomcat/webapps/프로젝트명1" > </ context ></ host > < host name = "URL2" xmlnamespaceaware = "false" xmlvalidation = "false" autodeploy = "true" unpackwars = "true" appbase = "webapps" > < context path = "" docbase = "/usr/local/tomcat/webapps/프로젝트명2" > </ context ></ host > </ engine > |