public class 클래스명 { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { super.doGet(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { super.doGet(req, resp); } }
@Controller
를 사용하면 요청을 매핑할 수 있는 컨트롤러 역할을 수행하는 클래스가됨@GetMapping
, @PostMapping
을 이용해 요청을 매핑@Controller public class 클래스명 { @GetMappint("경로") public String 메소드명(파라미터){ ... } }
try(Connection conn = DriverManger.getConnection(dbUrl, username, password)){ Statement stmt = conn.createStatement(); // 트랜잭션 블락 시작 conn.setAutoCommit(false); String SQL = "SQL문" stmt.execyteUpdate(SQL); // 트랙잭션 블락 끝, 커밋 conn.commit() conn.setAutoCommit(true) } catch(SQLEcepion e){ 예외처리 메시지 출력 // 트랜잭션 취소 conn.rollback(); }
@Transactional(속성 = 속성값) public 반환타입 메소드명(매개변수) throws 예외{ ... }