• springMVC在jsp传对象到后台


    ==============实体entity=======================

    package com.jb.pub.entity;

    import java.io.Serializable;

    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.ManyToOne;

    import com.jb.tool.Savebackground;


    /**
     * 用户
     */
    @Entity
    public class Pubuser implements Serializable {
     private static final long serialVersionUID = 8235691405047796440L;

     private String aguid; 

      public String getAguid() {
      return aguid;
     }

     public void setAguid(String aguid) {
      this.aguid = aguid;
     }


    }

    =============action===================

    package com.jb.pub.controller;

    import java.io.IOException;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.ModelMap;
    import org.springframework.web.bind.annotation.RequestMapping;

    import com.jb.pub.entity.Pubbm;
    import com.jb.pub.entity.Pubjob;
    import com.jb.pub.entity.Pubuser;
    import com.jb.pub.services.PubuserServices;
    import com.jb.tool.JTool;
    import com.jb.tool.JToolType;

    @Controller
    @RequestMapping("index")
    public class PubuserAction {
     @Autowired
     public PubuserServices pub;

     @RequestMapping("mgAdd")
     public String saveUser(Pubuser pubuser,HttpServletRequest request){//Pubuser pubuser一定要设置为参数
      try {   
       pub.savUser(pubuser);//添加的方法
       
      } catch (Exception e) {
      e.printStackTrace();
      
      }finally{
       return "PubUser_gl";
      }
     }

    ===============jsp===========================

     <form action="index/mgAdd.do" method="post" id="frmadd">
         <input type="text" name="aguid"/><!--注意这里必须和实体名称一致-->

    </form>

  • 相关阅读:
    随机生成三十个二年级的加减乘除法的题目代码
    学习进度表_四周
    返回一个整数数组中最大子数组的和1
    学习进度表_三周
    四则运算4
    构建之法读书笔记2
    学习进度表_二周
    四则运算3
    四则运算2
    单元测试
  • 原文地址:https://www.cnblogs.com/qgc88/p/3309658.html
Copyright © 2020-2023  润新知