my eclipse中servlet的doget方法快捷键?

my eclipse中servlet的doget方法快捷键


千巷猫影
浏览 1716回答 2
2回答

有只小跳蛙

方法如下:USERFORM.JSP<%@ page language="java"contentType="text/html;charset=gb2312"%><html><head><title>用户表单</title></head><body><formaction="DoGetDemo" method="get">用户名:<input type="text"name="username"/><br>密码:<input type="password"name="password"/><br><input type="submit"value="提交"/><input type="reset"value="重置"/></form></body></html>OK,接下来相对应的Servlet代码如下:package com.javaweb.ch10;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class DoGetDemo extends HttpServlet {publicvoid doGet(HttpServletRequest request, HttpServletResponseresponse)throws ServletException, IOException {response.setContentType("text/html;charset=gb2312");PrintWriter out = response.getWriter();request.setCharacterEncoding("gb2312");String username = request.getParameter("username");String password = request.getParameter("password");out.println("<html>");out.println("<body>");out.println("用户名:" + username +"<br>");out.println("密码:" + password);out.println("</body>");out.println("</html>");}}

慕哥9229398

快捷键不知道有没有,不过我一般这样弄也挺快的,一般我们写servlet时让那个类继承自HttpServlet,ctrl+s保存一下,然后选中你的类名,右击鼠标,然后点Override/Implment Methods,选择doGet点OK就有了。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

WebApp