javaee servlet简单操作
input.html <from action="login" method="post"> user:<input type="txet" name="name" /> adim:<input type="password" name="name"/> <type="submit" vlaue="提交"> </form> Login.java public calss Login extends HttpServlet{ public void doPost(HtppServletRequest rest,HttpServletResponse resp ) throws ServletException,IOException{ rest.setcharacterEncoding("utf-8"); String name= rest.getparameter("name"); String password= rest.getparameter("password"); rest.setAttribute("name",name); rest.setAttribute("password",passwoed); rest.getRequestDispatcher("output.jsp").forward(rest,resp); } } wed.xml <servlet> <servlet-name>lg</servlet-name> <servlet-class>Login</servlet-class> </servlet> <servlet-mapping> <servlet-name>ls<servlt-name> <url-pattern>/login<url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp<welcome-file> </welcome-file-list> output.jsp user:${name}; passwoed:${password} input.html <from action="login" method="post"/> <input type="txet" name="name" /> <input type="passwrod" name="passwrod"/> <input type="submit"/> </form> Login.java pulib class Login extends HttpSverlet{ pulib void doPost(HttpSverletRequest requst ,HttpSverletResponse rese){ requst.setcharacterEncoding } }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步