분류 | 게시판 |
베스트 |
|
유머 |
|
이야기 |
|
이슈 |
|
생활 |
|
취미 |
|
학술 |
|
방송연예 |
|
방송프로그램 |
|
디지털 |
|
스포츠 |
|
야구팀 |
|
게임1 |
|
게임2 |
|
기타 |
|
운영 |
|
임시게시판 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <mapper namespace= "userControlMapper" > <select id ="selectAll" parameterType="java.util.HashMap" resultType= "java.util.HashMap"> select * from tsst </select> <select id="select" parameterType="java.util.HashMap" resultType= "java.util.HashMap"> select * from tsst where idx = #{idx} </select> <insert id="insert"> insert into tsst(val1, val2, val3) value(#{val1}, #{val2}, #{val3}) </insert> <delete id="delete" parameterType="int"> delete from tsst where idx = #{idx} </delete> <update id="update"> update tsst set val1=#{val1}, val2=#{val2}, val3=#{val3} where idx=#{idx} </update> </mapper> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /** * Handles requests for the application home page. */ @Controller public class HomeController { @Autowired private SqlSession sqlSession; /** * Simply selects the home view to render by returning its name. */ @RequestMapping(value = "/result", method = RequestMethod.POST) public ModelAndView home(Locale locale, Model model, HttpServletRequest request, HttpServletResponse response) { try { request.setCharacterEncoding("UTF-8"); String val1 = request.getParameter("val1"); String val2 = request.getParameter("val2"); String val3 = request.getParameter("val3"); String check = request.getParameter("check"); if(check.equals("select")) { int idx = Integer.parseInt(request.getParameter("selectIdx")); /* 여기가 문제!!! */ } else { try{ if(check.equals("insert")) { Vo vo = new Vo(val1, val2, val3); sqlSession.insert("userControlMapper.insert", vo); } else if(check.equals("delete")) { Vo vo = new Vo(val1, val2, val3); int idx = Integer.parseInt(request.getParameter("delIdx")); sqlSession.delete("userControlMapper.delete", idx); } else if(check.equals("update")) { int idx = Integer.parseInt(request.getParameter("upIdx")); Vo vo = new Vo(idx, val1, val2, val3); sqlSession.update("userControlMapper.update", vo); } } catch(Exception e){ } List<HashMap<String, String>> outputs = sqlSession.selectList("userControlMapper.selectAll"); ModelAndView mav=new ModelAndView("result","m" , outputs); return mav; } } catch(Exception e){ } return null; } } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | public class Vo { private String val1; private String val2; private String val3; private int idx; public Vo(String val1, String val2, String val3){ this.val1 = val1; this.val2 = val2; this.val3 = val3; } public Vo(int idx, String val1, String val2, String val3){ this.idx = idx; this.val1 = val1; this.val2 = val2; this.val3 = val3; } public int getIdx(){ return idx; } public void setIdx(){ this.idx = idx; } public String getVal1() { return val1; } public void setVal1(String val1) { this.val1 = val1; } public String getVal2() { return val2; } public void setVal2(String val2) { this.val2 = val2; } public String getVal3() { return val3; } public void setVal3(String val3) { this.val3 = val3; } } | cs |
죄송합니다. 댓글 작성은 회원만 가능합니다.