表单传入

前端代码:

<form method="POST" id="user_login_submit">
<div class="form-group">
<label for="email">E-Mail Address</label>
<input id="email" type="email" class="form-control" name="email" value="" required autofocus>
</div> <div class="form-group">
<label for="password">Password
<a href="forgot.html" class="float-right">
Forgot Password?
</a>
</label>
<input id="password" type="password" class="form-control" name="password" required data-eye>
</div> <div class="form-group">
<label>
<input type="checkbox" name="remember"> Remember Me
</label>
</div> <div class="form-group no-margin">
<button id="login_btn" type="submit" class="btn btn-primary btn-block">
Login
</button>
</div>
<div class="margin-top20 text-center">
Don't have an account? <a href="register.html">Create One</a>
</div>
</form>
$(function () {
$("#user_login_submit").submit(function () {
$.ajax({
url: "/bengmall/login",
type: "post",//方法类型
dataType: "json",//预期服务器返回的数据类型
success: function (data) {
console.log("提交成功");
},
error: function (data) {
alert("登录過程中出現錯誤!"+data.result["result"].message);
}
})
});
});

前端中传入了一个name 为 email , 一个为 password , 后端使用了一个类来接收数据

@RequestMapping(value = "/login")
public String login(User user, HttpServletRequest request, HttpServletResponse response) { ... }
public class User
{
private String email;
private String password; public String getEmail() {
return email;
} public void setEmail(String email) {
this.email = email;
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
}
}

URL 路径

当传递一些不重要的数据时,只是为了查询使用时,可以通过URL 路径中放置参数查询。

@PathVariable

  1 //http://weibo.com/user1,http://weibo.com/user2
2 @RequestMapping("/usermanager/{username}")
3 public String userManager(@PathVariable("username")String name )
4 {
5 return "usermanager";
6 }
7

@RequestParam

  1    // http://localhost:8080/springmvc/hello/101?param1=10&param2=20
2 public String getDetails(
3 @RequestParam(value="param1", required=true) String param1,
4 @RequestParam(value="param2", required=false) String param2){
5 ...
6 }

参考资料:

1.https://blog.csdn.net/u011410529/article/details/66974974

Spring 数据传入的更多相关文章

  1. ASP.NET MVC搭建项目后台UI框架—8、将View中选择的数据行中的部分数据传入到Controller中

    目录 ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NET MVC搭建项目后台UI框架—3.面板折叠和展开 ASP.NE ...

  2. View中选择的数据行中的部分数据传入到Controller中

    将View中选择的数据行中的部分数据传入到Controller中   ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NE ...

  3. Spring数据访问之JdbcTemplate

    Spring数据访问之JdbcTemplate 使用JdbcTemplate的基本操作步骤 1.引jar包

  4. 005-spring-data-elasticsearch 3.0.0.0使用【三】-spring-data之Spring数据扩展

    续 1.8.Spring数据扩展 这些扩展使Spring Data在各种环境下的使用成为可能.目前大部分的整合都是针对Spring MVC. 1.8.1.Querydsl扩展 Querydsl是一个框 ...

  5. Spring MVC自定义消息转换器(可解决Long类型数据传入前端精度丢失的问题)

    1.前言 对于Long 类型的数据,如果我们在Controller层通过@ResponseBody将返回数据自动转换成json时,不做任何处理,而直接传给前端的话,在Long长度大于17位时会出现精度 ...

  6. 三、Spring——数据访问

    1.Spring 对 DAO的支持 Spring支持目前大多数常用的数据持久化技术,Spring定义了一套面向DAO层的异常体系,并未各种支持的持久化技术提供了异常转换器.这样,我们在设计DAO接口时 ...

  7. 在EasyUI中统一判断是否有选中行,如果有则将选中行数据传入回调函数

    function procossWithSeletedData(func) { var rowData = $("#tbGrid").datagrid("getSelec ...

  8. 记spring mvc传入List<Object>的一次尝试

    首先,看一段异常: org.springframework.http.converter.HttpMessageNotReadableException: Could not read documen ...

  9. Spring数据访问和事务

    1.模型 2.解耦 3.实现 3.1 核心接口 3.2 代码分析 3.2.1 事务管理 3.2.2 数据访问 4.使用 4.1 编程模式 4.2 配置模式 4.2.1 声明式配置方式 4.2.2 注解 ...

随机推荐

  1. [SDOI2009] HH的项链 | 莫队模板

    题目链接:戳我 题意:求区间中不同颜色的种类数 因为是要过知识点,所以又把这题拿出来做了一遍......这里就写两种方法吧 主席树做法 设pre[i]为第i个点上的颜色在前面序列中出现的最晚的一次的位 ...

  2. 蛋疼的Action.c (141): undeclared identifier `LAST'异常

    之前这个脚本运行了很久都没有问题,今天突然在场景运行不了: Action.c (141): undeclared identifier `LAST' 害的老子一直在纠结,这个关联函数没有问题啊,怎么一 ...

  3. 6.iptables常用规则

    开启ip段192.168.1.0/24端的80口 开启ip段211.123.16.123/24端ip段的80口 # iptables -I INPUT -p tcp --dport 80 -j DRO ...

  4. Windows下使用DOS命令进入MySQL数据库

    先要配置环境变量 MYSQL_HOME : D:\mysql-8.0.11-winx64 Path:%MYSQL_HOME%\bin 1)新建MYSQL_HOME变量,并配置:C:\Program F ...

  5. php sapi 产生core 文件

    php sapi 产生core 文件 1) vim /usr/local/php7.1.6-debug/etc/php-fpm.conf rlimit_core = 0 改为 rlimit_core ...

  6. [集合]Collection集合框架源码分析

    Collection接口 在java的集合类库中,基本接口是Collection,该接口的在集合中的源码定义如下(将源码中的注释删掉了): public interface Collection< ...

  7. openstack 使用pbr配置,setup.cfg的格式与含义

    pbr - Python Build Reasonableness A library for managing setuptools packaging needs in a consistent ...

  8. ubuntu->错误

    1.dpkg *** locked 原因:安装某个包不成功, 可以使用命令 dpkg --configure -a 来重启中断的安装过程 如果屡次安装不成功放弃安装,则删除 lock 2.flashp ...

  9. (USB HID) Report Descriptor 理解

    在這理整理一下基本 Report Descriptor 對於入門基礎的了解. 在很多文件.Blog都有提到HID report 總共分為3種 : Input.Output.Feature report ...

  10. Navigator 传值

    iOS 导航器 http://wiki.jikexueyuan.com/project/react-native/navigator-ios.html import React, { Componen ...