2015년 1월 30일 금요일

fmt

<%@ page language="java" contentType="text/html; charset=EUC-KR"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:useBean id="date" class="java.util.Date"/>
<html>
<head>
<title>JSTL fmt 라이브러리 사용 예제</title>
</head>
<body>
<%-- <fmt:setLocale value="ko_KR" scope="session"/>  언어를 한글로 지정시 --%>
<fmt:setLocale value="en_US" scope="session"/>
<fmt:bundle basename="test">
 <fmt:message key="name"/><br>
 <fmt:message key="say"/><br>
 <fmt:message key="say2">
  <fmt:param value="고길동"/>
 </fmt:message>
</fmt:bundle>
<p>
<fmt:formatNumber value="50000" type="currency"/><br>
<fmt:formatNumber value="0.15" type="percent"/><br>
<fmt:formatNumber value="500567300" pattern="###,###,###"/><p>
<fmt:formatDate value="${date}" type="date"/><br>
<fmt:formatDate value="${date}" type="time"/><br>
<fmt:formatDate value="${date}" type="both"/><p>
<fmt:formatDate value="${date}" type="both"
timeStyle="short" dateStyle="short"/><br>
<fmt:formatDate value="${date}" type="both"
timeStyle="long" dateStyle="long"/><br>
</body>
</html>

숫자1 : <fmt:formatNumber value="123456789" type="number"/><br>
숫자2 : <fmt:formatNumber value="1000" type="currency" currencySymbol="₩"/><br>
숫자3 : <fmt:formatNumber value="0.3" type="percent"/><br>
숫자4 : <fmt:formatNumber value="12345.678" pattern=".00"/><br>


<결과값>
숫자1 : 123,456,789  <- 기본 천단위 끊어서 표현
숫자2 : ₩ 1,000.00  <- 원표시 붙이고 (,)붙이고 소수점 2개 까지 표현
숫자3 : 30%   <- %로 표현
숫자4 : 12345.68  <- 설정 소수점에서 반올림으로 표

2015년 1월 28일 수요일

json

jsp=============================================================
<%@page import="org.json.simple.JSONObject"%>
<%@page import="org.json.simple.JSONArray"%>
<%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String com_cont = String.valueOf(request.getAttribute("com_cont"));
String file_name = String.valueOf(request.getAttribute("file_name"));
String file_true_name = String.valueOf(request.getAttribute("file_true_name"));
String fl_idx = String.valueOf(request.getAttribute("fl_idx"));

JSONObject js_obj = new JSONObject();
js_obj.put("com_cont",com_cont);
js_obj.put("file_name",file_name);
js_obj.put("file_true_name",file_true_name);
js_obj.put("fl_idx",fl_idx);
out.print(js_obj.toJSONString());
%>

javascript======================================================
 $.ajax({    
        type:"POST",
        url:url,    
        data:params,
        dataType: "json",
        success:function(resultData){
            //$("#result").html(args);
            //console.log(resultData);
            //var com_cont = $(resultData).find("com_cont").html();              
            var com_cont = resultData.com_cont;
            setReplyForm(com_idx,com_cont);          
        },
        //beforeSend:showRequest,
        error:function(e){
            alert(e.responseText);
        }
    });

2015년 1월 27일 화요일

selectKey

인서트 후 시퀀스 값 반환
<insert id="ins_com_return" parameterClass="com">  
   INSERT INTO com VALUES(sq_com.NEXTVAL,#com_cont#,#mem_idx#,SYSDATE,#task_idx#)
   <selectKey resultClass="int">
       SELECT sq_com.CURRVAL FROM DUAL
   </selectKey>


// 결과 맵 반환
<select id="sel_pow_user" parameterClass="map" resultClass="org.apache.commons.collections.map.CaseInsensitiveMap">

2015년 1월 26일 월요일

FormData

var formData = new FormData();

formData.append("username", "Groucho");
formData.append("accountnum", 123456); // number 123456 is immediately converted to string "123456"

// HTML file input user's choice...
formData.append("userfile", fileInputElement.files[0]);

// JavaScript file-like object...
var content = '<a id="a"><b id="b">hey!</b></a>'; // the body of the new file...
var blob = new Blob([content], { type: "text/xml"});

formData.append("webmasterfile", blob);

var request = new XMLHttpRequest();
request.open("POST", "http://foo.com/submitform.php");
request.send(formData);

scrolltop

<div id="target"></div>
<a href="#target" class="scroll">Scroll to target</a>
<script>
jQuery(document).ready(function($) {
        $(".scroll").click(function(event){  
                event.preventDefault();
                $('html,body').animate({scrollTop:$(this.hash).offset().top}, 500);
        });
});
</script>

2015년 1월 21일 수요일

array()

-array copy
var clone = myArray.slice(0);

-array delete
.splice(0);

삭제: .pop();, 추가: .push(var);

지정삭제

arrayObj.splice(start, deleteCount, [item1[, item2[, . . . [,itemN]]]])

java list -> javascript array

var rouletteArr = new Array(); //["기프티콘","마일리지 500점","마일리지 100점","기프티콘","마일리지 2,000점","마일리지 50점"];
<c:forEach items="${resultList}" var="item">
    rouletteArr.push("${item.rouletteSeq}");
</c:forEach>

vo List 일때는 이렇게

  var dataList = new Array();
  var dataObj = new Object();
  var categoryName = "";
<c:forEach items="${resultList}" var="result">
   categoryName = "${result.categoryName}";
   dataObj[categoryName] = new Object();
   dataObj[categoryName].categoryName = "${result.categoryName}";
   dataObj[categoryName].weekStartDt = "${result.weekStartDt}";
   dataObj[categoryName].weekEndDt = "${result.weekEndDt}";
   dataObj[categoryName].sessionAll = "${result.sessionAll}";
   dataObj[categoryName].sessionDistinct = "${result.sessionDistinct}";
   dataObj[categoryName].loginAll = "${result.loginAll}";
   dataObj[categoryName].loginDistinct = "${result.loginDistinct}";
   dataList.push(dataObj[categoryName]);
</c:forEach>
 사용할때는 이렇게
$.each(dataList, function(index){
    categoryStr += "<category name='"+ this.weekStartDt + " - " + (this.weekEndDt).substring(5) + "' /> \n";
});

forEach문으로 루프 돌려서 Array 오브젝트에 넣어주면 됨.

[출처] java List to javascript Array , java vo list to javascript array list |작성자 키키
http://hongy0225.blog.me/220183635327

2015년 1월 20일 화요일

input , select 크기 맞추기

A solution?

Then we discovered this:


.form-text {
        -moz-box-sizing:border-box;
        -webkit-box-sizing:border-box;
        box-sizing:border-box;
}

Combining the two sets of CSS above results in form elements that look like this:



Depending on your choice of browser, there’s a good chance the two elements above are now the same width.

What is the “box-sizing” property?

An explanation of the “box-sizing” property from the W3Schools website is as follows:

“The box-sizing property allows you to define certain elements to fit an area in a certain way. For example, if you’d like two bordered boxes side by side, it can be achieved through setting box-sizing to ‘border-box’. This forces the browser to render the box with the specified width and height, and place the border and padding inside the box.”

This “fix” appears to work in Internet Explorer 8 and above, Firefox, Safari and Chrome. Without it, we could never find a way of making the elements the same width even with specific width, padding, margin and border properties.

input, textarea 적용