博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
7-14
阅读量:6969 次
发布时间:2019-06-27

本文共 2314 字,大约阅读时间需要 7 分钟。

hot3.png

  1. sql语句

        SELECT userid as userid, username as username FROM user WHEREuserid = #userId#;

      insert into user values (#userId#,#username#);

    update user set username = #username# WHERE userid = #userId#

2.      IE(客户端提出请求)——>controller——>model——>controller——>jsp

3.     @Autowired   自动注入,不需要声明实例对象

4.     controller

package cn.training.controller;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import cn.training.bean.UserBean;import cn.training.service.HelloWorldService;@Controller("HelloWorldController")@RequestMapping("/")public class HelloWorldController {	@Autowired	HelloWorldService helloWorldService;	    @RequestMapping(value = "/", method = RequestMethod.GET)    public String index(Model model) {        return "helloWorld";    }        @RequestMapping(value = "/init", method = RequestMethod.POST,params="login")    public String initLogin(UserBean userBean, Model model) {    	    	UserBean result = helloWorldService.searchUser(userBean);    	model.addAttribute("userBean", result);        return "login";    }    @RequestMapping(value = "/init", method = RequestMethod.POST,params="add")      public String intinsert(UserBean userBean, Model model) throws Exception  {    	int insert = helloWorldService.insert(userBean);    	if(insert==1)    	{    	UserBean result= new UserBean();    		model.addAttribute("userBean", result);    		model.addAttribute("message", "ok");    	     return "insertSuccess";    	}else    	{    		throw new Exception();    	}    	    	    }  @RequestMapping(value = "/initupdate", method = RequestMethod.POST,params="update")    public String intupdate(UserBean userupdate, Model model)  { 	  int update = helloWorldService.updateUser(userupdate);     	        if(update==1)   	{    	        model.addAttribute("userBean", userupdate);    		model.addAttribute("message", "ok");   	        return "login2";     	}else   	{   		model.addAttribute("message", "false");  	        return "login2";   	}           }  }

5.javabean

6.${userBean.userId}"获取来自controller的值

7首先在jsp页面-〉controller->model->controller->jsp

实现数据的插入 查询 删除

转载于:https://my.oschina.net/u/2411987/blog/478790

你可能感兴趣的文章
如何实现密码域灰色默认提示?
查看>>
zabbix
查看>>
JAVA--虚函数,抽象函数,抽象类,接口
查看>>
解决 You could try using --skip-broken to work around the problem
查看>>
php清楚squid缓存
查看>>
openstack Folsom版本安装
查看>>
Cisco Catalyst 交换机一直处于rommon模式无法启动IOS问题的解决
查看>>
java io以及unix io模型
查看>>
syslog及syslog-ng详解
查看>>
UITableViewController
查看>>
我的友情链接
查看>>
Java源码分析系列之HttpServletRequest源码分析
查看>>
如何通过命令行创建和设置一个MySQL用户
查看>>
WPF DrawingContext Pen
查看>>
Wordpress+LNMP 环境搭建
查看>>
小步快跑是这样玩的(下)
查看>>
rsync工作方式介绍03
查看>>
Windows 7蓝屏自动重启,无法修复的处理办法
查看>>
SSH-Struts2、Spring和Hibernate应用实例
查看>>
Objective-C 类别(Category)浅谈
查看>>