表单传入

前端代码:

<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. ng 发生 Error: ELOOP: too many symbolic links encountered...

    ng g component components/home 发生如下提示: 由于使用 cnpm install 安装 node_modules 导致这样. 解决办法: 删除 node_modules ...

  2. system idle process

    偶然发现windows环境任务管理其中存在进程 system idle process,cpu占用极大但内存占用很小.google了一下,保存下结果 system idle process :系统空闲 ...

  3. [HAOI2010]计数(组合数学)(数位DP)

    原题题意也就是给的数的全排列小于原数的个数. 我们可以很容易的想到重复元素的排列个数的公式. 但是我们发现阶乘的话很快就会爆long long啊(如果您想写高精请便) 之后我就尝试质因数分解....但 ...

  4. NOIP前刷题记录

    因为本蒻实在太蒻了...对于即将到来的NOIP2018ssfd,所以下决心要把自己近期做过的题目(衡量标准为洛谷蓝题难度或以上)整理一下,归归类,简单地写一下思路,就当作自己复习了吧qwq 本随笔持续 ...

  5. Delphi编程中使用回车键不换行处理方法!!

    我以前遇到过Delphi编程中使用回车键不换行的问题,一直没有找到正确处理方法,以至于每次都重新安装Delphi,今天在XE8中再次遇到这样问题,万幸找到了正确的解决方法: 可能使用过程中不小心按了i ...

  6. [ActionScript 3.0] 实现放大镜效果的简单方法

    //mc和bgmc是同一对象的不同实例 //mc放大的对象 //bgmc源对象 //mag放大镜 var scale:Number = 1.3;//放大倍数 mc.mask = mag; mag.st ...

  7. NSCharacter​Set 关于字符串编码

    此文转自:http://nshipster.cn/nscharacterset/ 只为个人为了查找问题方便才复制过来的....... 正如之前提前过的,基础类库(Foundation)拥有最好的.功能 ...

  8. UIEvent笔记

    UIEvent是什么 代表iOS系统中的一个事件. UIEvent分为三类,touch events, motion events, and remote-control events touch e ...

  9. proxy思考

    vue从2.5版本之后开始强化typescript的支持程度,在ide方面增强对visual stadio的支持,更重要的是,双数据绑定那一块,要使用es6的proxy来代替Object.define ...

  10. leetcode-551-Student Attendance Record I(判断是否出现连续几个相同字符)

    题目描述: You are given a string representing an attendance record for a student. The record only contai ...