页面之间传递值,mvc参数问题(前后台)
来源:互联网 发布:智能卡算法工具 编辑:程序博客网 时间:2024/04/30 18:40
页面之间传递值===============
用内置对象request以一个页面
<%request.setAttribute("txt", "生活服务") %>
第二个页面
<%String txt = request.getAttribute("txt") %>(属性)
<th><%=txt %></th>
也可以吧一个页面的“生活服务”作为参数(?txt=生活服务)传到第二个页面,用<%request.getParameter("txt") %>获取就行了(参数)
这种就是相当于在值栈中,也可直接用<input type="hidden" name="roleid" id="roleid" value="${id}">
var roleId=$("#roleid").val();//这样就实现了jsp--js//隐藏域
==================================
model中add的,跳转时传的参数是,传给后面要跳转的页面,在mvc中注解表明的往往是要跳转的页面,标签下面的方法参数是前面请求这个页面的参数,方法体是处理这些参数后返回给注解的参数,隐藏域,就是在跳转之前用?或model.set传入,然后注解页面用隐藏域获取,之后js获取
向即将跳转页面传值
return "redirect:index.do?szie=1";
model.addAttribute(“szie”,szie);,index接收到size后跳转前modeladd才可到值栈中,被index直接用jstl表达式用
model.addObject("parentMenus", parentMenus); ///////////////////////////////////////////////////////////////一个key,对应对个value
不用回调用值栈,用model.addAttribute 此时jsp用此
<%-- <c:choose>
<c:when test="${roledetl.status==1}">
<input class="width_240" name="status" value=" 有效" />
</c:when>
<c:when test="${roledetl.status==0}">
<input class="width_240" name="status" value=" 无效" />
</c:when>
</c:choose> --%>
<%-- <c:if test="${roledetl.status==1}">
<input class="width_240" name="status" value=" 有效" />
</c:if> --%>
<select name="status" class="width_240">
<option value="1" <c:if test="${roledetl.status==1}">selected="selected"</c:if>>有效</option>
<option value="0" <c:if test="${roledetl.status==2}">selected="selected"</c:if>>无效</option>
</select>
<select name="status" class="width_240">
<option value="0" selected="selected">===请先选择===</option>
<c:forEach items="${item}" var="item" >
<option value="${item.id }" selected="selected">${item.name }</option>
</c:forEach>
</select>
不用回调用值栈,用model.addAttribute前台用jstl表达式
==============================================================
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<td><select name="org" class="width_240">
<option value="0" selected="selected">===请先选择===</option>
<c:forEach items="${orgs}" var="item" >
<option value="${item.id }" >${item.orgName }</option>
</c:forEach>
</select>
</td>
@RequestMapping(value = "/edit")
public void edit(Long id,Model model) {
if (id != null) {
User roledetl = userService.getUserForEditById(id);
model.addAttribute("roledetl", roledetl);
List<Organization> orgs= organizationService.getOrganization();
model.addAttribute("orgs", orgs);
// model.addAttribute("areas", acountService.getDictDataListByTypeCodeAndParentId(StaticUtil.PROVINCE_CITY, organization.getCityId()));
}
// model.addAttribute("provinces", acountService.getDictDataListByTypeCode(StaticUtil.PROVINCE_CITY));
// model.addAttribute("roledetl",null);
}
===================================
方法二 model.addObject("parentMenus", parentMenus); ///////////////////////////////////////////////////////////////一个key,对应对个value
<c:forEach items="${parentMenus}" var="parent">
<c:choose>
<c:when test="${parent.isleaf=='0'}">
<div class="titleArea_normal" ><i class="icon_spgl"></i>${parent.menuName}</div>
<div class="box3" style="display: none">
<c:forEach items="${parent.childs}" var="item">
<c:choose>
<c:when test="${!empty item.url}">
<a class="list" href="${pageContext.request.contextPath}${item.url}" target="mainFrame"><span>${item.menuName}</span></a>
</c:when>
<c:otherwise>
<a class="list" href="javascript:void(0)" target="mainFrame"><span>${item.menuName}</span></a>
</c:otherwise>
</c:choose>
</c:forEach>
</div>
</c:when>
<c:when test="${parent.isleaf=='1'}">
<a class="titleArea_normal firstShow" href="${pageContext.request.contextPath}${parent.url }" target="mainFrame"><i class="icon_home1"></i>${parent.menuName}<input type="hidden"/></a>
</c:when>
</c:choose>
</c:forEach>
方法三 直接用@ResponseBody 结合ajax
隐藏域
页面a var roles = "<a name='showMenu' href='${pageContext.request.contextPath}/system/users/userroles.do?id=" + lineData["id"] + "' class='cyan'>【授用户组】</a>";
String id = request.getParameter("id");
<%=id %>
隐藏域
@RequestMapping(value = "/userroles")
public void checkbox( @RequestParam Long id ,Model model ) {
model.addAttribute("id", id);
}
<div>
<input id="userId" type="hidden" value="${id }">
</div>
用内置对象request以一个页面
<%request.setAttribute("txt", "生活服务") %>
第二个页面
<%String txt = request.getAttribute("txt") %>(属性)
<th><%=txt %></th>
也可以吧一个页面的“生活服务”作为参数(?txt=生活服务)传到第二个页面,用<%request.getParameter("txt") %>获取就行了(参数)
这种就是相当于在值栈中,也可直接用<input type="hidden" name="roleid" id="roleid" value="${id}">
var roleId=$("#roleid").val();//这样就实现了jsp--js//隐藏域
==================================
model中add的,跳转时传的参数是,传给后面要跳转的页面,在mvc中注解表明的往往是要跳转的页面,标签下面的方法参数是前面请求这个页面的参数,方法体是处理这些参数后返回给注解的参数,隐藏域,就是在跳转之前用?或model.set传入,然后注解页面用隐藏域获取,之后js获取
向即将跳转页面传值
return "redirect:index.do?szie=1";
model.addAttribute(“szie”,szie);,index接收到size后跳转前modeladd才可到值栈中,被index直接用jstl表达式用
model.addObject("parentMenus", parentMenus); ///////////////////////////////////////////////////////////////一个key,对应对个value
不用回调用值栈,用model.addAttribute 此时jsp用此
<%-- <c:choose>
<c:when test="${roledetl.status==1}">
<input class="width_240" name="status" value=" 有效" />
</c:when>
<c:when test="${roledetl.status==0}">
<input class="width_240" name="status" value=" 无效" />
</c:when>
</c:choose> --%>
<%-- <c:if test="${roledetl.status==1}">
<input class="width_240" name="status" value=" 有效" />
</c:if> --%>
<select name="status" class="width_240">
<option value="1" <c:if test="${roledetl.status==1}">selected="selected"</c:if>>有效</option>
<option value="0" <c:if test="${roledetl.status==2}">selected="selected"</c:if>>无效</option>
</select>
<select name="status" class="width_240">
<option value="0" selected="selected">===请先选择===</option>
<c:forEach items="${item}" var="item" >
<option value="${item.id }" selected="selected">${item.name }</option>
</c:forEach>
</select>
不用回调用值栈,用model.addAttribute前台用jstl表达式
==============================================================
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<td><select name="org" class="width_240">
<option value="0" selected="selected">===请先选择===</option>
<c:forEach items="${orgs}" var="item" >
<option value="${item.id }" >${item.orgName }</option>
</c:forEach>
</select>
</td>
@RequestMapping(value = "/edit")
public void edit(Long id,Model model) {
if (id != null) {
User roledetl = userService.getUserForEditById(id);
model.addAttribute("roledetl", roledetl);
List<Organization> orgs= organizationService.getOrganization();
model.addAttribute("orgs", orgs);
// model.addAttribute("areas", acountService.getDictDataListByTypeCodeAndParentId(StaticUtil.PROVINCE_CITY, organization.getCityId()));
}
// model.addAttribute("provinces", acountService.getDictDataListByTypeCode(StaticUtil.PROVINCE_CITY));
// model.addAttribute("roledetl",null);
}
===================================
方法二 model.addObject("parentMenus", parentMenus); ///////////////////////////////////////////////////////////////一个key,对应对个value
<c:forEach items="${parentMenus}" var="parent">
<c:choose>
<c:when test="${parent.isleaf=='0'}">
<div class="titleArea_normal" ><i class="icon_spgl"></i>${parent.menuName}</div>
<div class="box3" style="display: none">
<c:forEach items="${parent.childs}" var="item">
<c:choose>
<c:when test="${!empty item.url}">
<a class="list" href="${pageContext.request.contextPath}${item.url}" target="mainFrame"><span>${item.menuName}</span></a>
</c:when>
<c:otherwise>
<a class="list" href="javascript:void(0)" target="mainFrame"><span>${item.menuName}</span></a>
</c:otherwise>
</c:choose>
</c:forEach>
</div>
</c:when>
<c:when test="${parent.isleaf=='1'}">
<a class="titleArea_normal firstShow" href="${pageContext.request.contextPath}${parent.url }" target="mainFrame"><i class="icon_home1"></i>${parent.menuName}<input type="hidden"/></a>
</c:when>
</c:choose>
</c:forEach>
方法三 直接用@ResponseBody 结合ajax
隐藏域
页面a var roles = "<a name='showMenu' href='${pageContext.request.contextPath}/system/users/userroles.do?id=" + lineData["id"] + "' class='cyan'>【授用户组】</a>";
String id = request.getParameter("id");
<%=id %>
隐藏域
@RequestMapping(value = "/userroles")
public void checkbox( @RequestParam Long id ,Model model ) {
model.addAttribute("id", id);
}
<div>
<input id="userId" type="hidden" value="${id }">
</div>
0 0
- 页面之间传递值,mvc参数问题(前后台)
- 前后台传递参数
- 前后台参数传递(&,%处理)
- 前后台,页面间传递多个参数
- java关于前后台页面之间跳转的路径问题
- Spring MVC前后台传递JSON
- Struts2前后台参数传递总结
- jsp 前后台值传递
- jsp中利用jquery+ajax传递json格式参数与前后台之间
- jsp中利用jquery+ajax传递json格式参数与前后台之间
- 页面之间传递参数的问题
- 前后台页面参数互传
- 页面之间传递参数.
- 页面之间传递参数
- 页面之间传递参数
- spring mvc 前后台json交互问题
- springmvc Jsp页面向后台传递中文参数乱码问题
- MVC特性---轻松实现前后台数据的传递
- ztree
- 【转】Google Cloud SQL 发布
- 养成良好的工作习惯。
- ajaxsetup,结合拦截器处理session过期,跳转登录页面
- TIOBE 2011年9月编程语言排行榜:编程语言D回归前20
- 页面之间传递值,mvc参数问题(前后台)
- 请定义一个宏,比较两个数a、b的大小,不能使用大于、小于、if语句
- java环境变量配置
- jQuery ajax get请求编码问题,jQuery ajax简化处理,jQuery ajax与Servlet交互
- 【转】图解HTTPS
- 用springMVC做一个多页的用户注册过程
- 栈中函数调用原理_详解
- 【版本升级】MyEclipse 2017 CI 4发布(附下载)
- 使用github作为博客引擎