Skip to content

18.07.12

chy edited this page Jul 31, 2018 · 2 revisions
[MySQL] CASE Function
CASE
    WHEN Quantity > 30 THEN "The quantity is greater than 30"
    WHEN Quantity = 30 THEN "The quantity is 30"
    ELSE "The quantity is something else"
END
[Spring] Interceptor preHandle

preHandle : false return ์‹œ controller๋กœ ์š”์ฒญ์ด ๋„˜์–ด๊ฐ€์ง€ ์•Š์Œ

[MySQL] ๋ฐ˜์˜ฌ๋ฆผ, ๋ฒ„๋ฆผ

ROUND

  • SELECT ROUND(3456.1234567 ,1) โ†’ 3456.1
  • SELECT ROUND(3456.1234567 ,-1) โ†’ 3460

TRUNCATE

  • SELECT TRUNCATE(3456.1234567 ,1) โ†’ 3456.1
  • SELECT TRUNCATE(3456.1234567 ,-1) โ†’ 3450
[Java] ์—ฌ๋ž˜ ๊ฐœ์˜ ๊ฐ’์„ ๊ฐ€์ง„ map ๋งŒ๋“ค๊ธฐ
Map<String, Integer> hashMap = new HashMap<String, Integer>()
{{
     put("One", 1);
     put("Two", 2);
     put("Three", 3);
}};

๋งค๋ฒˆ ์ƒˆ๋กœ์šด ํด๋ž˜์Šค๋ฅผ ์ƒ์„ฑํ•˜๋ฏ€๋กœ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋„๋ก ํ•˜์ž

[Spring] forwared ModelMap
@RequestMapping("/foo")
public String foo(ModelMap model) {    
    model.put("foo", "foo");
    return "forward:/bar";
}

@RequestMapping("/bar")
public String bar(HttpServletRequest request, ModelMap model) {    
    request.getAttribute("foo"); // "foo"
    return "something";
}

controller์—์„œ foward ๊ธฐ๋Šฅ์„ ์ด์šฉ์‹œ, Model์˜ ์ •๋ณด๋Š” request์˜ attribute ํ˜•์‹์œผ๋กœ ์ „๋‹ฌ

[Js] replaceAll or replace with regex
'aaaa'.replace('a','2') // '2aaa'
'aaaa'.replace(/a/g,'2') // '2222'

regex ํ‘œํ˜„์‹์„ ์ด์šฉํ•  ๋•Œ๋Š” ' ๋˜๋Š”"์„ ๋ถ™์ด๋ฉด ์•ˆ๋จ

Clone this wiki locally