IDEA中实现用户信息修改功能

这篇博客详细介绍了在IDEA中实现用户信息修改功能的步骤,包括从数据库读取用户信息展示在前端,使用form表单提交更新信息,并通过ajax实现页面无刷新显示更新结果。涉及mapper、service类的编写,以及依赖于jquery和easyui框架的js文件的使用。
摘要由CSDN通过智能技术生成
       实现用户信息修改功能,首先从数据库中读取用户个人信息在前台页面展示,通过修改用户某些字段信息,以form表单提交的方式,将修改后用户的信息进行保存到数据库,同时页面无刷新的显示更新后的用户数据信息
整个项目结构图如下所示:

项目结构

第一步,mapper类的书写
1 在数据库中查询该用户的所有信息
2 进数据库信息的更新
详细代码如下:
package test.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import test.entity.Stu;

import java.util.List;

@Component
public interface Common {

    //登陆成功后查询用户的学号
    @Select("select sno from stu where sno=#{sno} and password=#{password}")
    public String getsno(@Param("sno") String sno,@Param("password") String password);

    //登陆成功后查询用户的姓名
    @Select("select sname from stu where sno=#{sno} and password=#{password}")
    public String login(@Param("sno") String sno,@Param("password") String password);

    //登陆成功后查询用户的所有信息
    @Select("select * from stu where sno=#{sno}")
    public Stu userinfor(@Param("sno") String sno);

    //用户信息的更新操作
    @Update("update stu set sname=#{sname},password=#{password},tno=#{tno},tname=#{tname},tgrade=#{tgrade} where sno=#{sno}")
    public void updateStu(@Param("sno") String sno,@Param("sname") String sname,@Param("password") String password,@Param("tno") String tno,@Param("tname") String tname,@Param("tgrade") String tgrade);

}
第二步,service类的调用mapper中的方法
代码如下:
package test.service;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import test.entity.Stu;
import test.mapper.Common;

import java.util.List;

@Service
public class CommonService {
   
    @Autowired
    public Common commonmapper;

    public String getsno(String sno,String password){
        return commonmapper.getsno(sno, password);
    }

    public String login(String sno, String password){
        return commonmapper.login(sno, password);
    }

    public Stu userinfor(String sno){
        return commonmapper.userinfor(sno);
    }

    public void updateStu(String sno,String sname,String password,String tno,String tname,String tgrade){
        commonmapper.updateStu(sno, sname, password, tno, tname, tgrade);
    }

}
第三步,service类的调用mapper中的方法
代码如下:
package test.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值