⚡ select, date, color
<body> <form method="post" action="./htmlcode_ok.do" id="f" enctype="application/x-www-form-urlencoded"> 통신사 : <select name="corp"> <option value="">통신사를 선택하세요</option> <option value="SKT">SKT</option> <option value="KT">KT</option> <option value="KT">LGT</option> <option value="알뜰폰">알뜰폰</option> </select> <br><br> 예약 일자 및 시간 : <input type="datetime-local" name="today"> <br><br> 색상 선택 : <input type="color" name="color"> <input type="button" value="전송" onclick="gopage()"> </form> </body> <script type="text/javascript"> function gopage(){ f.submit(); } </script>
public class htmlcode_ok extends HttpServlet { private static final long serialVersionUID = 1L; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=utf-8"); request.setCharacterEncoding("utf-8"); String corp = request.getParameter("corp"); String today = request.getParameter("today").replaceAll("T", " ") + ":00"; String color = request.getParameter("color"); System.out.println(corp); //KT : option value로 전송 System.out.println(today); //2024-05-29T12:42 -> replace System.out.println(color); //#f71d1d } }
'CLASS > SERVLET' 카테고리의 다른 글
#3-1 / form 예제 (0) | 2024.05.30 |
---|---|
#2-4 / double form (0) | 2024.05.29 |
#2-2 / 검색에 따른 get 전송방식 (0) | 2024.05.29 |
#2-1 / checkbox 및 라디오 핸들링 (0) | 2024.05.29 |
#1-2 / Front form태그 + servlet (0) | 2024.05.28 |