zoukankan      html  css  js  c++  java
  • servlet点滴

    注意:

    1 路径问题,以地址栏上拼凑出的完整地址为准

    2

    Code
    public class FormServlet extends HttpServlet
    {
        
    private ServletConfig config = null ;
        
    public void init(ServletConfig config) throws ServletException 
        {
            
    this.config = config ;
        }
        
    // 表示处理get请求
        public void doGet(HttpServletRequest req,HttpServletResponse resp) throws IOException,ServletException
        {
            
    // System.out.println("** Servlet doGet处理提交参数 ") ;
            this.doPost(req,resp) ;
        }
        
    // 处理post请求
        public void doPost(HttpServletRequest req,HttpServletResponse resp) throws IOException,ServletException
        {
            String name 
    = req.getParameter("uname") ;
            
    // 取得application对象
            
    // ServletContext app = this.getServletContext() ;
            ServletContext app = this.config.getServletContext() ;
            app.setAttribute(
    "addr","www.MLDN.cn") ;
            
    // 取得一个session对象
            HttpSession session = req.getSession() ;
            session.setAttribute(
    "sname",name) ;
            
    // System.out.println("** Servlet doPost处理提交参数 ") ;
            System.out.println("name = "+name) ;
            
    // 重定向
            resp.sendRedirect("demo.jsp") ;
        }
    };

  • 相关阅读:
    select 标签的数据绑定
    JQ选择器-选择符合条件的元素,获取对应关系元素
    Velocity中判断表达式是不是为空
    重要的serialVersionUID
    编译nginx的时候报错 需要安装PCRE
    Mac 允许安装任何来源的app
    Charles
    Excel_日期和时间函数、EDATE、EOMONTH
    项目9: 成绩中国式排名(难度:中等)
    Mysql:IFNULL的使用说明
  • 原文地址:https://www.cnblogs.com/zhxiaomiao/p/1427483.html
Copyright © 2011-2022 走看看