SpringMVC 前后台参数传递问题 5C

前端参数为:var jsonData = {
"id":id,
"jsonDateForDetail":jsonDateForDetail,
"contractCode":contractCode,
"contractName":contractName,
"contractType":contractType,
"signingDate":signingDate,
"shipperId":shipperId,
"shipperName":shipperName,
"companyAbbreviation":companyAbbreviation,
"carrierId":carrierId,
"carrierName":carrierName,
"shipperContactPerson":shipperContactPerson,
"shipperContactNumber":shipperContactNumber,
"carrierContactPerson":carrierContactPerson,
"carrierContactNumber":carrierContactNumber,
"cashOnDeliveryRatio":cashOnDeliveryRatio,
"settlementMethod":settlementMethod,
"departureAddress":departureAddress,

"arrivalAddress":arrivalAddress,
"consignmentPeriod":consignmentPeriod,
"shippingType":shippingType,
"deliveryMode":deliveryMode,
"numConfirmationMethod":numConfirmationMethod,
"qaConfirmationMethod":qaConfirmationMethod,
"remark":remark,
"status":status,
"contractProvision":contractProvision,
"auditPerson":auditPerson,
"auditTime":auditTime,
"auditOpinion":auditOpinion,
//后加的
"flag":flag
};

Wb.request({
url:reqUrl ,
params: jsonData,
success: function(resp) {
app.appwin.hide();
app.appwinAudit.hide();
app.appgrid.store.reload();

if(oprType=="audit"){

Ext.Msg.alert('{#app_alert#}', "审核通过");
}else{
Ext.Msg.alert('{#app_alert#}', "保存成功");
}
}
});

我新增的实体类:
public class TransportVo extends RmValueObject{
private static final long serialVersionUID = 1L;
private String id;

private String contractCode;

private String contractType;

private String contractName;

private Timestamp signingDate;

private String shipperId;

private String shipperName;

private String companyAbbreviation;

private String carrierId;

private String carrierName;

private String shipperContactPerson;

private String shipperContactNumber;

private String carrierContactPerson;

private String carrierContactNumber;

private BigDecimal cashOnDeliveryRatio;

private String settlementMethod;

private String departureAddress;

private String arrivalAddress;

private String consignmentPeriod;

private String shippingType;

private String deliveryMode;

private String numConfirmationMethod;

private String qaConfirmationMethod;

private String remark;

private String status;

private String auditPerson;

private Timestamp auditTime;

private String auditOpinion;

private String usableStatus;

private Timestamp createTime;

private String createIp;

private String createUserId;

private String createUserName;

private Timestamp modifyTime;

private String modifyIp;

private String modifyUserId;

private String modifyUserName;

private Timestamp deleteTime;

private String deleteIp;

private String deleteFlag;

private String deleteUserId;

private String deleteUserName;

private String orderCode;

private String attribute1;

private String attribute2;

private String attribute3;

private String attribute4;

private String contractProvision;

public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

public String getContractCode() {
    return contractCode;
}

public void setContractCode(String contractCode) {
    this.contractCode = contractCode;
}

public String getContractType() {
    return contractType;
}

public void setContractType(String contractType) {
    this.contractType = contractType;
}

public String getContractName() {
    return contractName;
}

public void setContractName(String contractName) {
    this.contractName = contractName;
}

public Timestamp getSigningDate() {
    return signingDate;
}

public void setSigningDate(Timestamp signingDate) {
    this.signingDate = signingDate;
}

public String getShipperId() {
    return shipperId;
}

public void setShipperId(String shipperId) {
    this.shipperId = shipperId;
}

public String getShipperName() {
    return shipperName;
}

public void setShipperName(String shipperName) {
    this.shipperName = shipperName;
}

public String getCompanyAbbreviation() {
    return companyAbbreviation;
}

public void setCompanyAbbreviation(String companyAbbreviation) {
    this.companyAbbreviation = companyAbbreviation;
}

public String getCarrierId() {
    return carrierId;
}

public void setCarrierId(String carrierId) {
    this.carrierId = carrierId;
}

public String getCarrierName() {
    return carrierName;
}

public void setCarrierName(String carrierName) {
    this.carrierName = carrierName;
}

public String getShipperContactPerson() {
    return shipperContactPerson;
}

public void setShipperContactPerson(String shipperContactPerson) {
    this.shipperContactPerson = shipperContactPerson;
}

public String getShipperContactNumber() {
    return shipperContactNumber;
}

public void setShipperContactNumber(String shipperContactNumber) {
    this.shipperContactNumber = shipperContactNumber;
}

public String getCarrierContactPerson() {
    return carrierContactPerson;
}

public void setCarrierContactPerson(String carrierContactPerson) {
    this.carrierContactPerson = carrierContactPerson;
}

public String getCarrierContactNumber() {
    return carrierContactNumber;
}

public void setCarrierContactNumber(String carrierContactNumber) {
    this.carrierContactNumber = carrierContactNumber;
}

public BigDecimal getCashOnDeliveryRatio() {
    return cashOnDeliveryRatio;
}

public void setCashOnDeliveryRatio(BigDecimal cashOnDeliveryRatio) {
    this.cashOnDeliveryRatio = cashOnDeliveryRatio;
}

public String getSettlementMethod() {
    return settlementMethod;
}

public void setSettlementMethod(String settlementMethod) {
    this.settlementMethod = settlementMethod;
}

public String getDepartureAddress() {
    return departureAddress;
}

public void setDepartureAddress(String departureAddress) {
    this.departureAddress = departureAddress;
}

public String getArrivalAddress() {
    return arrivalAddress;
}

public void setArrivalAddress(String arrivalAddress) {
    this.arrivalAddress = arrivalAddress;
}

public String getConsignmentPeriod() {
    return consignmentPeriod;
}

public void setConsignmentPeriod(String consignmentPeriod) {
    this.consignmentPeriod = consignmentPeriod;
}

public String getShippingType() {
    return shippingType;
}

public void setShippingType(String shippingType) {
    this.shippingType = shippingType;
}

public String getDeliveryMode() {
    return deliveryMode;
}

public void setDeliveryMode(String deliveryMode) {
    this.deliveryMode = deliveryMode;
}

public String getNumConfirmationMethod() {
    return numConfirmationMethod;
}

public void setNumConfirmationMethod(String numConfirmationMethod) {
    this.numConfirmationMethod = numConfirmationMethod;
}

public String getQaConfirmationMethod() {
    return qaConfirmationMethod;
}

public void setQaConfirmationMethod(String qaConfirmationMethod) {
    this.qaConfirmationMethod = qaConfirmationMethod;
}

public String getRemark() {
    return remark;
}

public void setRemark(String remark) {
    this.remark = remark;
}

public String getStatus() {
    return status;
}

public void setStatus(String status) {
    this.status = status;
}

public String getAuditPerson() {
    return auditPerson;
}

public void setAuditPerson(String auditPerson) {
    this.auditPerson = auditPerson;
}

public Date getAuditTime() {
    return auditTime;
}

public void setAuditTime(Timestamp auditTime) {
    this.auditTime = auditTime;
}

public String getAuditOpinion() {
    return auditOpinion;
}

public void setAuditOpinion(String auditOpinion) {
    this.auditOpinion = auditOpinion;
}

public String getUsableStatus() {
    return usableStatus;
}

public void setUsableStatus(String usableStatus) {
    this.usableStatus = usableStatus;
}

public Date getCreateTime() {
    return createTime;
}

public void setCreateTime(Timestamp createTime) {
    this.createTime = createTime;
}

public String getCreateIp() {
    return createIp;
}

public void setCreateIp(String createIp) {
    this.createIp = createIp;
}

public String getCreateUserId() {
    return createUserId;
}

public void setCreateUserId(String createUserId) {
    this.createUserId = createUserId;
}

public String getCreateUserName() {
    return createUserName;
}

public void setCreateUserName(String createUserName) {
    this.createUserName = createUserName;
}

public Date getModifyTime() {
    return modifyTime;
}

public void setModifyTime(Timestamp modifyTime) {
    this.modifyTime = modifyTime;
}

public String getModifyIp() {
    return modifyIp;
}

public void setModifyIp(String modifyIp) {
    this.modifyIp = modifyIp;
}

public String getModifyUserId() {
    return modifyUserId;
}

public void setModifyUserId(String modifyUserId) {
    this.modifyUserId = modifyUserId;
}

public String getModifyUserName() {
    return modifyUserName;
}

public void setModifyUserName(String modifyUserName) {
    this.modifyUserName = modifyUserName;
}

public Date getDeleteTime() {
    return deleteTime;
}

public void setDeleteTime(Timestamp deleteTime) {
    this.deleteTime = deleteTime;
}

public String getDeleteIp() {
    return deleteIp;
}

public void setDeleteIp(String deleteIp) {
    this.deleteIp = deleteIp;
}

public String getDeleteFlag() {
    return deleteFlag;
}

public void setDeleteFlag(String deleteFlag) {
    this.deleteFlag = deleteFlag;
}

public String getDeleteUserId() {
    return deleteUserId;
}

public void setDeleteUserId(String deleteUserId) {
    this.deleteUserId = deleteUserId;
}

public String getDeleteUserName() {
    return deleteUserName;
}

public void setDeleteUserName(String deleteUserName) {
    this.deleteUserName = deleteUserName;
}

public String getOrderCode() {
    return orderCode;
}

public void setOrderCode(String orderCode) {
    this.orderCode = orderCode;
}

public String getAttribute1() {
    return attribute4;
}

public void setAttribute1(String attribute1) {
    this.attribute1 = attribute1;
}

public String getAttribute2() {
    return attribute2;
}

public void setAttribute2(String attribute2) {
    this.attribute2 = attribute2;
}

public String getAttribute3() {
    return attribute3;
}

public void setAttribute3(String attribute3) {
    this.attribute3 = attribute3;
}

public String getAttribute4() {
    return attribute4;
}

public void setAttribute4(String attribute4) {
    this.attribute4 = attribute4;
}

public String getContractProvision() {
    return contractProvision;
}

public void setContractProvision(String contractProvision) {
    this.contractProvision = contractProvision;
}

}

后台方法:
@RequestMapping(params = {"method=insert"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}, consumes = {"application/x-www-form-urlencoded"}, produces = {"application/json"})

@ResponseBody
public Map insert(HttpServletRequest request, @Valid TransportVo vo){。。。。。}

为什么TransportVo 这个实体没有值呢?如果把后面这个实体参数删掉就可以请求跳转到后台。但问题是,我的项目中其他的页面也是这么写的就可以传值---前台传一个JSONDATA,后台方法有两个参数,页面发送请求之后,后台方法中这两个参数都有值。而我新建的页面却不行

我想知道是什么地方给这另外加的实体类赋值了呢?

7个回答

新加的实体类代码贴一下

tjh434471446
JieHaoT 回复SugaryoTT: 加上注解应该能解析了
大约一年之前 回复
SugaryoTT
SugaryoTT 贴到里面了~
大约一年之前 回复

打断点debug呢,看看后台接收到的值是什么

SugaryoTT
SugaryoTT 如果后台我去掉了TransportVo这个参数,那么就可以传到后台,可以DEBUG。但是加了这个实体参数,就不可以了。问题是项目中别的页面也是这样,就可以传值
大约一年之前 回复

我想到一个可能的方向:浏览器会预判你的动作;也就是说浏览器会预先存储一些东西,默认帮你赋值了。建议查找方向是:浏览器预加载。
请参考。

你传的是json,本质还是一个String字符串,后台就用String类型接受,用一个Bean(TransportVo )怎么接收得到?

传过来的本质是String. 可以通过工具来解析封装成实体类(有相关jar工具)。或设置拦截器直接解析。以后再出再这种问题就直接接受实体类就简单了

你检查下其他的地方的 params: jsonData, 这个**jsonData**也是你这样写的吗?

后台无jsonDateForDetail字段 后台不能少字段 少了是无法接收到数据的

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
前后台之间的参数传递问题
如何在页面不刷新的情况下,将前台的参数传到后台去?
对于axios.post的前后台的参数传递问题
axios 可以看成是另一种ajax,就是负责向后台进行请求和数据传递的组件 一般我们在前台页面请求后台时,如果数据量不大的情况下,get方式请求完全可以实现,如下: var projectid = 1; axios.get('../tplusbranch/gettplusbranchs.json',  params: {//请求数据   "projectid":projectid }
Struts2前后台参数传递
前端向后台传递参数 在后台获取前端传递的参数时,一定要创建get(),set()方法,使用对象驱动时还要保证存在无参构造 1.属性驱动获得参数 通过在Action类中创建与前端页面中name值相同的属性值,并创建get()与set()方法,同时还可以自动转换数据类型,但是只支持8大基本数据类型以及包装类的转换. 在下面代码中user与pwd都能获取到 private String us...
spring前后台参数传递
controller接收参数最好使用引用类型 不要使用int等基本类型参数 直接使用基本类型做参数时因为如果不传递该参数 后台会报参数转换异常
SpingMVC框架前后台参数传递
前端传后台 在目标方法内添加形参,形参名与前端请求的参数名一直或者使用注解绑定 @Controller public class Login { @RequestMapping("/login") //前端请求中的参数名为userName与psw public String login(@RequestParam("userName&
springmvc 参数传递问题
输入查询条件查询能够显示第一页查询结果,但是点击翻页出错,nRequired String parameter 'filename' is not presentn参数无法获取,不知什么原因,求大神nnnjsp页面代码nn```n nn <%n HttpSession s = request.getSession(); n n n %>n <%String s1=s.getAttribute("pagenum").toString();n String s2=s.getAttribute("pagesize").toString();n String s3=s.getAttribute("pagenow").toString();n String s4=s.getAttribute("num").toString();n int pagenum=Integer.parseInt(s1);n int pagesize=Integer.parseInt(s2);n int pagenow=Integer.parseInt(s3);n int pagenow2=Integer.parseInt(s3)+1;n int listnum=Integer.parseInt(s4);n int liststep=5;//显示页码数n n if (pagenum < pagenow) n pagenow = pagenum;//如果分页变量大总页数,则将分页变量设计为总页数 n n if (pagenow <=0) n pagenow = 1;//如果分页变量小于1,则将分页变量设为1 n n else if (pagenow >0) n pagenow = pagenow+1;//如果分页变量小于1,则将分页变量设为1 n n n int listbegin = (pagenow - (int) Math.ceil((double) liststep / 2));//从第几页开始显示分页信息 n if (listbegin < 1) //当前页-(总显示的页列表数/2) n listbegin = 1; n n int listend = (pagenow + liststep / 2)-1;//分页信息显示到第几页//当前页+(总显示的页列表数/2) n if (listend > pagenum) n listend = pagenum + 1; n n if(listnum<=10)n n listend=1;n if(listend-listbegin+1>pagenum)n n listend=pagenum;n if(listend>pagenum)n n listend=pagenum;n %>nnnn 上传任务管理nnn$pageactionn nn n n 查询nn n 文件名称:n n文件类型: ntxtnjpgnnnn n n上传时间从: n n至: nnn n n nnnnnnn $errormessagenn nn n nn n n idn 文件名n 文件大小n 文件类型n 上传时间n 文件描述n 执行时间n 运行结果n 操作n n n n $upload.idn $upload.filenamen $upload.filesizen $upload.filetypen $upload.uploaddaten $upload.desn $upload.runtimen $upload.resultn 编辑 删除 n n n n n 当前第:<%=pagenow%>页/共<%=pagenum %>页 显示<%=pagesize %>条/共<%=listnum %>条n n n n n <% if (pagenow > 1) n n %> <% n out.println("上一页"); n n n %> <%for(int i=listbegin;i<=listend;i++) n n n pagenow=i;n %> n n <% n if(i==pagenow2)n out.println("["+i+"] ");n elsen out.println("["+i+"] ");n n n %> n nn <% if (pagenow !=pagenum) n n %> <% n if(listnum!=0)n out.println("下一页"); n %> n n n n nnnnnnn nnn```njsp页面n![图片说明](https://img-ask.csdn.net/upload/201511/11/1447217989_777414.png)nncontroller代码nnnn```n @RequestMapping(value="/searchByFileName2/pagenow")n public ModelAndView searchByFilename(HttpServletRequest request,@RequestParam String filename,@RequestParam String filetype,@RequestParam String start,@RequestParam String stop, ModelMap mod) throws ParseExceptionn nn WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();n ServletContext application = webApplicationContext.getServletContext();n String n=(String) application.getAttribute("name");n System.out.println("sssssssssss "+n);n System.out.println("***************filename"+filename);n System.out.println("***************start"+start);n System.out.println("***************stop"+stop);n System.out.println("***************filetype"+filetype);nn ModelAndView modelAndView=new ModelAndView("user/uploadWithPage");n if(start.equals("")&!stop.equals(""))n n mod.addAttribute("errormessage", "上传日期不能为空");n return modelAndView;n n if(!start.equals("")&stop.equals(""))n n mod.addAttribute("errormessage", "上传日期不能为空");n return modelAndView;n n n n Page uploa=null;n if(filename.equals("")&start.equals("")&stop.equals(""))n n uploa=uploadService.findUploadByUsernameAndFiletype(n, filetype, 0, pagesize);n n n else if(start.equals("")&stop.equals(""))n n uploa=uploadService.findUploadByUsernameAndFilenameAndFiletype(n, filename, filetype, 0, pagesize);n n else if(filename.equals("")&!start.equals("")&!stop.equals(""))n n uploa=uploadService.findUploadByUsernameAndFileTypeAndUploaddate(n, filetype, start, stop, 0, pagesize);n n else if(!filename.equals("")&!start.equals("")&!stop.equals(""))n n uploa=uploadService.findUploadByAll(n, filename, filetype, start, stop, 0, pagesize);n n elsen n mod.addAttribute("errormessage", "上传日期不能为空");n n //当前页查询的记录数n pageitems=uploa.getNumberOfElements();n //查询出的总记录数n itemsnum=(int)uploa.getTotalElements();n n //总页数n pagenum=uploa.getTotalPages();n HttpSession session = getSession();n session.setAttribute("pagenum", pagenum);n session.setAttribute("pagesize", pagesize);n session.setAttribute("num", itemsnum);n session.setAttribute("pagenow", pagenow);n session.setAttribute("filename", filename);n session.setAttribute("filetype", filetype);n session.setAttribute("start", start);n session.setAttribute("stop", stop);n mod.addAttribute("filename", filename);n List u = uploa.getContent();n if(u.size()==0)n n mod.addAttribute("errormessage", "该文件不存在");n return modelAndView;n n mod.addAttribute("pageaction", "upload/searchByFileName2");n modelAndView.addObject("upload",u);n return modelAndView;n n```nnn
springMVC参数传递
Spring MVC 的请求参数获取 1.通过@PathVariabl注解获取路径中传递参数  @RequestMapping(value = "/{id}/{str}")     public ModelAndView helloWorld(@PathVariable String id,             @PathVariable String str) {        
SpringMVC参数传递
SpringMVC参数传递 使用原生的ServletAPI获取(request.getParameter("id")) 页面:     form action="login" method="post">        username:input type="text" name="name"/>br>        password:input type="
SpringMvc 参数传递
SpringMvc 参数传递 View to Controller 的两种方式: &amp;lt;1&amp;gt; @RequestMapping(value=&quot;/访问路径名&quot;,method=RequestMethod.GET,params=“与方法定义参数属性名相同”) 名在同类不能相同,可以在类处定义,也可以在方法处定义 &amp;lt;2&amp;gt; @RequestParam(value=“参数名”,require...
springmvc参数传递
在做一个分页功能的时候,使用springmvc,使用变量currentPage代表当前页面,打开页面的时候currentPage为1,修改页面的时候用get方法修改currentPage   @RequestParam(value=&quot;currentPage&quot;)   但是,每次打开都要加个小尾巴 :    ?currentPage=1 否则报无参数错误。   这时,可以设置默认值 ...
SpringMVC之参数传递
1. 通过设置HttpServletRequest request 来获取数据 jsp页面: 账号: 密码: 后台代码: @RequestMapping(value="/add1.do") public String add(HttpServletRequest request){ String userNumber = request.getParamete
springMVC前后台传值乱码问题
问题场景在项目中需要在前台传中文参数到controller里,debug时发现乱码,在controller向前台传值时,如果有中文也是乱码。解决方式一前提:项目采用utf-8编码a. 编辑web.xml,添加过滤 <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.
SpringMVC前后台Json转换
问题:SpringMVC框架下使用ajax与后台进行json数据交互失败maven中的jar包依赖: &amp;lt;!--json转换--&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;com.fasterxml.jackson.core&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;jackson-core&amp;lt;/a...
SpringMVC 前后台数据传输
SpringMVC 数据交互
springmvc的前后台连接
我从别人的类里加的方法,,别人的方法能够执行,但是我的就报404,说rnDEBUG - Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping@1eb2004] in DispatcherServlet with name 'dispatcher'rnDEBUG - No handler mapping found for [/userExamination/showCheckState],我在开头已经加上rn /**rn * 查询审核状态列表rn * @param modelrn * @param queryModelrn * @returnrn */rn @RequestMapping("showCheckState")rn public String showCheckState(Page page, Model model,BatchNoticePageModel queryModel,HttpServletRequest request),不知道怎么回事了。。。。。。
SpringMVC实现前后台数据交互
web.xml &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt; &amp;lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xsi:schemaLocation=&quot;http://java.sun.
SpringMVC前后台传值写法
前后台传值(参数,对象,集合)
SpringMVC前后台数据交互
SpringMVC前台ajax与后台控制器方法交互数据,ajax提交表单,控制器往前台写入json串
springmvc 前后台数据传递
对于springmvc前后台数据的传递  就只介绍json数据传递  因为开发中主要是要json数据的传递  在前端当然传输一个json数据到后台来 例如这样 其中user是一个json字符串 然后将其放入data中  springmvc中controller 里面有@requestBody User user 这是java后台自定义的一个类 里面具有属性 属性和前段传过来的js...
springmvc前后台传值方式
@Controller //下面的注解@RequestMapping相当于action中的namespace @RequestMapping("/") public class MyController implements ServletContextAware{ //注意让类实现ServletContextAware接口,就可以直接获取application对象 private Servlet...
ssm前后台ajax之类的参数传递
网上这部分的资料很多,这回遇到了,简单回顾下 js代码 $.ajax({ contentType : &amp;quot;application/json;charset=UTF-8&amp;quot;, url :'/userPerm/addResource', //请求后台的URL(*) dataType:&amp;quot;json&amp;quot;, ...
springMVC中关于参数传递的问题
有这么一个jsp页面 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.util.*" isELIgnored="false"%> 产品名称 : 产品价格: 有这一个pojo类 pac
Springmvc前后台数据数组绑定
Springmvc前后台数据数组绑定,list超过了256时,会报错,如何解决?该文给出了说明
SpringMvc 前后台list传值应用
Model  是 实体类 后台写入 @RequestMapping("/list") public String selectlist(Model m){ List users =userService.findAll(); m.addAttribute("kechengList",users); System.out.print(users); return "main/yemLi
SpringMVC前后台传值方法一
前台传后台 第一种:直接从HttpServletRequest中获取 第二种:通过参数获取 要求前台请求参数名称和后台函数形参名称一样 第三种:通过对象获取 要求前台请求参数名称和后台对象的属性名一样 第四种:通过@RequestParam获取 形式如:@RequestParam(value="...
springmvc中的数据绑定(前后台传递)
一:前后端数据的传递过程中肯定会涉及到数据的绑定,因为一个个参数单独接收很费事且代码效率会大大降低,下面就对各种类型的数据进行绑定。 重点:表单大量数据(多对象)的传递绑定 1、基本类型数据绑定 在controller中写一个int参数绑定的方法, @RequestMapping("/int") @ResponseBody public String getInt
SpringMVC中的前后台传值注意事项
1.前台设置contentType:"application/x-www-form-urlencoded",前台是JSON对象,后台接收方法可以是字符串、对象。示例如下: function remoteService(url,postData) { var res = ""; $.ajax({                 cache: true,                 t
springMVC 前后台传值与接收值
  @Controller@RequestMapping(&quot;/user&quot;)@SessionAttributes(&quot;loginUser&quot;)public class UserController {     @RequestMapping(value={&quot;/&quot;,&quot;/hello&quot;})    public String hello(int id,Map&amp;lt;String,Object&amp;gt; m...
SpringMVC(一):返回值及参数传递
一、返回值 1、返回一个jsp页面 /** * 返回一个jsp页面 * @return */ @RequestMapping(value=&amp;quot;/returnJsp&amp;quot;,method=RequestMethod.GET) public String returnJsp() { return &amp;quot;/testController/returnJsp&amp;quot;; } 访问:http://loc...
SpringMVC上传文件参数传递错误?
java类代码(部分):rnrnrn```rn@RequestMapping(value= "/doUpload", method = RequestMethod.POST)rn public String uploadFileHandler(HttpServletRequest request,Model model,rn @RequestParam("file") MultipartFile[] files)rn rn //Root Directoryrn String uploadRootPath = request.getServletContext().getRealPath("upload");rn System.out.println("uploadRootPath=" + uploadRootPath);rn File uploadRootDir = new File(uploadRootPath);rn if(!uploadRootDir.exists())//Creat if it not existsrn rn uploadRootDir.mkdirs();rn rn rn List uploadedFiles = new ArrayList();rn for (int i=0;irn<%rnString path = request.getContextPath();rnString basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";rn%>rnrnrnrn rn rn rn Upload Multi Filern rn rn rn rn rn rn rnrn rn rn rn Upload Multiple File:rn rn File to upload (1): rn File to upload (2): rn File to upload (3): rn File to upload (4): rn File to upload (5): rn rn rn rn rnrn```rnrnrnrnrn错误信息:rnHTTP Status 400 - Required MultipartFile[] parameter 'file' is not presentrnrntype: Status reportrnrnmessage: Required MultipartFile[] parameter 'file' is not presentrnrndescription: The request sent by the client was syntactically incorrect.rnrn初学者,百思不得其解
springMVC学习笔记---参数传递
springMVC的参数传递,在页面中获取到值后,controller中给参数赋值,然后在页面中提取出来 @Controller @RequestMapping("/data") public class DataController { @RequestMapping("/addUser") public String addUser() { return "/addUser";
springmvc之工作原理以及参数传递
index.jsp &amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&amp;gt; &amp;lt;!DOCTYPE&amp;gt; &amp;lt;html&amp;gt; &amp;lt;body&amp;gt; &amp;lt;a href=&quot;param1.do?name=mik
关于Springmvc的参数传递方法
1.如果传过来的参数名字和本来的不一样(静态参数) @RequestParam(defaultValue="0",value="id")long parentId  需要设置默认值 2.如果是动态 传输的那种,需要进行传递 @PathVariable long itemId 这个是动态传递参数进行下一步的传递
springMVC中的参数传递
springMVC中的参数传递 1 接收参数 1.1 @RequestParam接收 将表单传过来的username重命名为name 这种方式如果从地址栏进来且地址栏不输入要传的参数会报错400 @RequestMapping(value=&amp;amp;amp;amp;quot;/a&amp;amp;amp;amp;quot;) public String hello(@RequestParam(&amp;amp;amp;amp;quot;uname&amp;amp;amp;amp;quot;) S
SpringMVC之参数传递(一)
Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面。Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块。
SpringMVC之参数传递(二)
Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面。Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块。
SpringMVC入门--参数传递
接着上一篇的Test1Controller package com.Ace.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.PathVaria
SpringMVC 参数传递中文乱码
今天搭建项目时,使用SpringMVC从页面传参到后台,获取到的中文参数乱码。解决方法:1、检查所有页面编码是UTF-8格式。2、查看是否在web.xml文件中配置编码过滤器,配置如下:&amp;lt;filter&amp;gt; &amp;lt;filter-name&amp;gt;CharacterEncodingFilter&amp;lt;/filter-name&amp;gt; &amp;lt;filter-class&amp;gt;org.s...
SpringMVC参数传递方式
1、通过@RequestParam注解 例: @RequestMapping(value = "/update") public String update( @RequestParam(value = "age", required = false, defaultValue = "0") int age, RedirectAttributesModelMap model,H
SpringMVC初步-----参数传递
SpringMVC简单注解的意思package org.springmvc.learn.controller;import java.util.Map;import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.
相关热词 c# 标准差 计算 c#siki第五季 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池