request参数集合绑定实体实现defaultmodebinder
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Reflection;
namespace RequestParameter1.Controllers
{ public class Search { public string id { get; set; }
public string name { get; set; }
}
public class HomeController : Controller
{
public ActionResult Index()
{
Type Mytype = typeof(Search); string[] arr = Request.QueryString.AllKeys;
Search sear=new Search();
foreach(string key in arr)
{
Response.Write(string.Format("{0}={1}</br>",key,Request[key]));
PropertyInfo myproperinfo = Mytype.GetProperty(key);
if (myproperinfo != null)
{
myproperinfo.SetValue(sear, Request[key]);
}
} return Json(sear,JsonRequestBehavior.AllowGet);
return View();
} public ActionResult About()
{
ViewBag.Message = "Your application description page."; return View();
} public ActionResult Contact()
{
ViewBag.Message = "Your contact page."; return View();
}
}
}
request参数集合绑定实体实现defaultmodebinder的更多相关文章
- springMVC怎么接受前台传过来的多种类型参数?(集合、实体、单个参数)
创建一个实体:里面包含需要接受的多种类型的参数.如实体.list集合.单个参数.(因为springMVC无法同时接受这几种参数,需要创建一个实体包含它们来接受) 如接收User(bean里面包含Lis ...
- Spring MVC如何接收浏览器传递来的请求参数--request--形参--实体类封装
阅读目录 1. 通过HttpServletRequest获得请求参数和数据 2. 处理方法形参名==请求参数名 3. 如果形参名跟请求参数名不一样怎么办呢?用@RequestParam注解 4. 用实 ...
- 0056 Spring MVC如何接收浏览器传递来的请求参数--request--形参--实体类封装
浏览器总会向服务器传递一些参数,那么Spring MVC如何接收这些参数? 先写个简单的html,向服务器传递一些书籍信息,如下: <!DOCTYPE html> <html> ...
- SpringMVC-请求参数的绑定
绑定的机制 表单提交的数据都是k=v格式的 username=haha&password=123 SpringMVC的参数绑定过程是把表单提交的请求参数,作为控制器中方法的参数进行绑定的 要求 ...
- 16 SpringMVC 的请求参数的绑定与常用注解
1.SpringMVC 绑定请求参数 (1)支持的数据类型 基本类型参数: 包括基本类型和 String 类型POJO 类型参数: 包括实体类,以及关联的实体类数组和集合类型参数: 包括 List 结 ...
- SpringMVC源码之参数解析绑定原理
摘要 本文从源码层面简单讲解SpringMVC的参数绑定原理 SpringMVC参数绑定相关组件的初始化过程 在理解初始化之前,先来认识一个接口 HandlerMethodArgumentResolv ...
- C# 实体集合和实体转换成相应的string、XDocument、XElement、XDocument
https://msdn.microsoft.com/zh-cn/library/system.xml.linq.xelement(v=vs.110).aspx XElement.Parse 方法 ( ...
- springmvc请求参数的绑定和获取
请求参数的绑定和获取: 获取页面请求的参数,是javaweb必不可少的一个环节,在struts中,是通过再Action中定义属性,或者Model的方式进行数据绑定和获取.需要提供setter或gett ...
- SpringMVC中,前台jsp封装参数,绑定参数,传递参数到后台controller的过程详解
前台到后台的流程:前台jsp->后台:controller控制器层->service业务层->DAO数据访问层->数据库model模型层. 从上面流程可知,前台jsp的数据,想 ...
随机推荐
- js 弹层 提示
<!DOCTYPE html><html style="height: 100%;"><head lang="en"> &l ...
- Swift & OC 混编 浅析
转载自:http://www.infoq.com/cn/articles/wangyi-cartoon-swift-mixed-practice?utm_campaign=rightbar_v2&am ...
- 关于在jsp中的表达式
列子: <%List<F_dd_tourist_info_markup> tourists = (List<F_dd_tourist_info_markup>) requ ...
- 在WIN7/8下把XP装入VHD (下)
系统平台:win8.1,安装在C盘 操作目的:在win8.1下装一个VHD XP. 操作方法: 在http://www.cnblogs.com/mahocon/p/5212914.html里贴了一个 ...
- Lightoj 1004 - Monkey Banana Problem
题目链接:http://acm.hust.edu.cn/vjudge/contest/121396#problem/F http://lightoj.com/volume_showproblem.ph ...
- iOS之tabbar图片去除渲染以及字体颜色统一配置
转发:http://www.cnblogs.com/qianLL/p/5521228.html 方式一 代码实现 这种要写很多代码 ,每个控制器都要写 UIImage *image=[UII ...
- MOSFET与MOSFET驱动电路原理及应用(转)
源:http://www.micro-bridge.com/news/news.asp?id=258 在使用MOS管设计开关电源或者马达驱动电路的时候,大部分人都会考虑MOS的导通电阻,最大电压等,最 ...
- a href="javascript:void(0)" 是什么意思?加不加上有什么区别?
<A href="javascript:void(0)">点击</a>点击链接后不会回到网页顶部<A href="#">点击 ...
- HDU 2188 悼念512汶川大地震遇难同胞——选拔志愿者(基础巴什博奕)
最最最基础巴什博奕 #include<stdio.h> #include<iostream> #include<cstring> #include<cmath ...
- WebDriver(Selenium2) 常见异常及处理方法
http://uniquepig.iteye.com/blog/1568197 Exception NoSuchElementException Solutions 1. Check the l ...