Servlet Application 저장소에 상태값 저장하기
·
Web/servlet & jsp
서블릿은 application 저장소에 이전에 전달한 값을 저장할수있다 서블릿 코드 : @WebServlet("/test") public class test extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html; charset=UTF-8"); ServletContext application = request.getServletContext(); PrintWriter out = ..
Servlet 사용자 입력 배열형태로 받기
·
Web/servlet & jsp
배열형태로 받기위해서는 넘겨받는 파라미터의 이름이 같아야한다 서블릿코드 : @WebServlet("/test") public class test extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); String[] str = request.getParameterValues("..
Servlet Post요청 받기
·
Web/servlet & jsp
먼저 서블릿하나를 생성한후 아래와같이 코드를작성해준다 @WebServlet("/ServletPost") public class ServletPost extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String str = request.getParameter("str"); out.printf(str); } } 여기서 Post요청을 받는 코드는 String str = request.getParameter("str"); 코드인데 앞에 St..
Servlet Url Mapping
·
Web/servlet & jsp
인텔리제이 기준으로 어노테이션을 이용하는 방법과 XML파일을 이용하는 방법이있다. XML WEB-INF폴더의 web.xml 파일에 작성하면된다 서블릿 이름지정 클래스파일위치 서블릿이름 매핑할 주소 예를들어서 com.h0ch1.web 패키지안에 test라는 클래스를 /test로 매핑을 하기위해선 test com.h0ch1.web.test test /test 이런식으로 XML파일을 작성해주면 8080포트 기준 Tomcat서버를 실행시켜주었을때 localhost:8080/test 주소에 정상적으로 test클래스 내용이 표시된다 어노테이션 인텔리제이 기준으로 서블릿을 만들때 하단에 create java EE 6 anotated class를 선택해야한다 xml파일에 맵핑하는것보다 훨씬 간단하다. 이런식으로 @We..
[Spring Boot]@RestController, @RequestMapping을 이용해 Hello World띄우기
·
Web/Spring Boot
웹페이지에 Hello World문구 띄우기 전 포스팅에서 프로젝트를 생성한뒤 서버를 실행시키는것까지 했었다. 이번엔 @RestController와 @RequestMapping 어노테이션을 이용해서 Hello World를 띄어본다 import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @SpringBootApplication @..
[Spring Boot] IntelliJ 스프링부트 프로젝트 생성 / 개념 정리
·
Web/Spring Boot
스프링부트 핵심기능 의존성 주입(Dependency Injection) 관점지향 프로그래밍 (AOP) 스프링 MVC 웹 애플리케이션과 RESTful 웹 서비스 프레임워크 JDBC, JPA, JMS 지원 기능 내장 서버: WAR 파일을 배포할 필요 없이 내장된 Tomcat, Jetty, Unertow 를 이용해 실행할 수 있습니다. 간단한 라이브러리 관리: 많이 사용하는 라이브러리를 모아놓은 스타터 (Starter) POM 파일로 메이븐 설정이 쉬워집니다. 자동 설정: 더 이상 XML 설정이 필요하지 않습니다. 레퍼런스 가이드 (Reference Guide): 문서화가 잘 되어 있어서 개발할 때 찾아보기 편합니다. IntelliJ에서 프로젝트생성방법 먼저 maven으로 프로젝트를 생성해준다 프로젝트 이름을..
Spring 개념 정리
·
Web/Spring Boot
주요기능 - DI, AOP, MVC, JDBC 모듈 - spring-core : DI, IOC제공 spring-aop : AOP spring-jdbc : 데이타베이스 접근, 관리 spring-tx : 트랜젝션 기능 spring-webmvc : module, view, control pom.xml : 메이븐 설정파일(필요한 모듈다운)
자바스크립트 cheerio와 axios를 이용한 크롤링
·
Coding/Crawling
const axios = require('axios'); const cheerio = require('cheerio'); const url = "https://mrxx.tistory.com/category"; async function getHTML(){ try{ return await axios.get(url); }catch (error){ console.log(error); } } getHTML() .then(html => { var titlelist = []; const $ = cheerio.load(html.data); const $bodyList = $("div#content").children("article.entry"); $bodyList.each(function(i, elem){ titl..
Junyoung.dev
'분류 전체보기' 카테고리의 글 목록 (6 Page)