This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExampleServlet extends HttpServlet { | |
//doPost ์ฌ ์ ์ | |
@Override | |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | |
resp.setContentType("text/html; charset=UTF-8"); | |
// Response ๊ฐ์ฒด์ PrintWriter๋ฅผ ์ฌ์ฉํด ๋ธ๋ผ์ฐ์ ์ HTML์ ์ถ๋ ฅํ๋ค. | |
PrintWriter out = resp.getWriter(); | |
out.println("<HTML><HEAD><TITLE>HelloServlet</TITLE></HEAD>"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Data | |
@AllArgsConstructor | |
@NoArgsConstructor | |
public class Student { | |
private String id; | |
private String name; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableWebMvc | |
@ComponentScan("me.spring5.spittr.web") | |
public class WebConfig implements WebMvcConfigurer { | |
@Bean | |
public ViewResolver viewResolver() { | |
InternalResourceViewResolver resolver = new InternalResourceViewResolver(); //view resolver | |
resolver.setPrefix("/WEB-INF/views/"); | |
resolver.setSuffix(".jsp"); | |
resolver.setExposeContextBeansAsAttributes(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller | |
public class HomeController { | |
@RequestMapping(value = "/" ,method = RequestMethod.GET) | |
public String home() { | |
return "home"; //view name | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SpittrWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { | |
@Override | |
protected Class<?>[] getRootConfigClasses() { | |
return new Class[] {RootConfig.class}; | |
} | |
@Override | |
protected Class<?>[] getServletConfigClasses() { | |
return new Class[] {WebConfig.class, SwaggerConfig.class}; //์ค์ ํด๋์ค๋ฅผ ๋ช ์ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class URLreplace { | |
static String replaceSpaces(String s, int len) { | |
int spaceCount = 0, index, i = 0; | |
char[] originStr = s.toCharArray(); | |
for (i = 0; i < len; i++) { | |
if (originStr[i] == ' ') { | |
spaceCount++; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Permutation { | |
boolean permutation(String s, String t) { | |
if (s.length() != t.length()) { | |
return false; | |
} | |
//memo ์ ์ฅ ๊ณต๊ฐ | |
int[] marking = new int[128]; | |
//์ฒซ ๋ฒ์งธ ๋ฌธ์์ด์ memo +1 | |
char[] s_array = s.toCharArray(); | |
for (char c : s_array) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UniqueChars { | |
boolean isUniqueChars(String str) { | |
if (str.length() > 128) return false; | |
//๋ฏธ๋ฆฌ ์ ์ธ๋ ๋ฐฐ์ด -> ๋ฌธ์ ์์๊ฐ ๋ฑ์ฅํ ๋๋ง๋ค ๋ฉ๋ชจํ๋ ์ฉ๋๋ก ์ฌ์ฉ | |
boolean[] char_set = new boolean[128]; | |
for (int i = 0; i < str.length(); i++) { | |
//๊ฐ ๋ฌธ์์ด์ ๋ฌธ์ ์์๋ก ๋ณ๊ฒฝ | |
int val = str.charAt(i); | |
if (char_set[val]) { | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************** | |
Item01 ์ฅ์ 3> ํด๋น ๊ฐ์ฒด์ ํ์ ํ์ ์ ๋ฆฌํดํ ์ ์๋ค. | |
Item01 ์ฅ์ 4> ๋ฆฌํดํ๋ ๊ฐ์ฒด์ ํด๋์ค๊ฐ ์ ๋ ฅ ๋งค๊ฐ๋ณ์์ ๋ฐ๋ผ ๋ค๋ฅธ ๋ฆฌํด๊ฐ์ ๊ฐ๊ฒ ํ ์ ์๋ค. | |
*************************************************************/ | |
public class Drill { | |
private String id; | |
private int num; | |
public Drill() { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********************************************************************** | |
Item01 ์ฅ์ 2> ๊ฐ์ฒด๋ฅผ ํธ์ถ ํ ๋๋ง๋ค ๋งค๋ฒ ์๋ก์ด ๊ฐ์ฒด๋ฅผ ์์ฑํ ํ์๋ ์๋ค. | |
***********************************************************************/ | |
public class Drill { | |
private static final Drill GOOD_ID = new Drill.withId("minikuma"); | |
private static final Drill GOOD_NUM = new Drill.withNum(100); | |
private String id; | |
private int num; |
NewerOlder