본문 바로가기
반응형

전체 글79

[Django] ManyToManyField 추가 및 삭제 방법_ 예제 [Django] 파이썬 장고 ORM ManyToManyField 추가 및 삭제 방법_ 예제 테이블의 특정 컬럼에 대해서 다수의 옵션이 필요할 경우 ManyToManyField로 관리할 수 있다. 즉, 다 대 다 관계가 되는것이다. # 모델 샘플 Menu 모델의 option 컬럼은 ManyToManyField로 MenuOptionType을 타겟하고 있다. 즉 Menu 모델의 한 row에 대해서 option이 여러개 맵핑될 수 있다는 뜻이다. # ManyToManyFiel로 생성된 연동테이블 예시 Id Menu테이블 id MenuOptionType id 1 1 4 2 2 5 3 2 6 # 활용 방법 menu_list = Menu.objects.get(name='아이스아메리카노') menu_list.optio.. 2022. 5. 10.
[Java] JSON 포맷(format) 제거 _ (remove '\"' from json format) [Java] JSON 포맷(format) 제거 ■ JSON format 제거 /** * JSON format 제거 */ public static String getJSONFormatClean(String s) { if (s == null) { return null; } return s.replace("\\\\/", "\\/").replace("\\\"", """).replace("\\r\\n", " ").replace("\\n", " ").replace("\\\\", "\\"); } [keyword] 자바 JSON Format 제거, 자바 json 포맷 제거, 자바 json 형식 제거, remove '\"' from json format, remove all JSON formatting (not just.. 2022. 5. 6.
[Java] 자바 모바일 여부 체크하기 _ Mobile Check [Java] 자바 모바일 여부 체크하기 _ Mobile Check ■ Java Mobile 확인하기 /** * 모바일 여부 */ public static boolean isMobileChk(HttpServletRequest req) { String ua = req.getHeader("user-agent").toLowerCase(); String[] devices = { "iphone", "ipod", "ipad", "android", "blackberry", "windows ce", "nokia", "webos", "opera mini", "sonyericsson", "opera mobi", "iemobile" }; for (String d : devices) { if (ua.contains(d)) { .. 2022. 5. 4.
[Java] URLEncoder , URLDecoder 예제 _ UnsupportedEncodingException ■ 자바 URLEncoder /** * URLEncoder * @throws UnsupportedEncodingException */ public static String getURLEncode(String url) throws UnsupportedEncodingException { if (url == null) { return null; } try { return URLEncoder.encode(url, "UTF-8"); } catch (Exception e) { return ""; } } ■ 자바 URLDecoder /** * URLDecoder * @throws UnsupportedEncodingException */ public static String getURLDecode(String url).. 2022. 5. 4.
반응형