1.项目目录:
2.ageFormIDCard.jsp
<form action="ages" method="post"> <input type="submit" value="计算"/> </form>3.web.xml
<servlet> <servlet-name>MyServlet</servlet-name> <servlet-class>com.**.**.servletTest.AgeFromIDCard</servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet</servlet-name> <url-pattern>/ages</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>ageFormIDCard.jsp</welcome-file> </welcome-file-list>4.AgeFromIDCard.java(这里需要HttpServlet架包,在Java安装的目录的bin下有一个rt.jar引进就可以了)
public class AgeFromIDCard extends HttpServlet { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Calendar ca = Calendar.getInstance();