(项目笔记)<include>与<jsp:param>配合 传值
来源:互联网 发布:淘宝挂机是什么意思 编辑:程序博客网 时间:2024/05/29 14:50
在我的第一个博客上对jsp中的包含进行了说明,这里对其中的参数传值进行补充:
这是一个网站注册的例子 头部作为单独的一部分包含到主页面中,在注册完后 需要对头部的jsp传参。
代码如下:
indexservlet.java中的函数:
private void doregist(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {// TODO Auto-generated method stubString registerusername=request.getParameter("registerusername");registerusername = new String(registerusername.getBytes("ISO-8859-1"), "utf-8");String registerpassword=request.getParameter("registerpassword");String code=request.getParameter("code");request.getRequestDispatcher("index.jsp").forward(request, response);Userinfodao userinfodao=new Userinfodao();userinfodao.inputuser(registerusername, registerpassword);/*response.getWriter()request.setAttribute("username", registerusername);}
index.jsp中包含的代码
<div class="head"><jsp:include page="Head.jsp"><jsp:param value="${username}" name="username" /></jsp:include></div>
这里说明下 参值可通过标签<jsp:param value="${username}" name="username" /> value为值, name为作为传值的变量。
Head.jsp
<c:set value="${param.username}" var="talib"></c:set> //这里就是通过el表达式的到index.jsp中通过标签 <jsp:param >传过来的值<c:set value="" var="tali"></c:set>//${param.username} 类似request.getparameter("username")得带标签<jsp:param >中变量username的值<c:if test="${ talib ne tali}"><script type="text/javascript">document.getElementById("logina").style.display="none";document.getElementById("registera").style.display="none";document.getElementById("c-header-right-user-name").style.display="block";document.getElementById("c-header-right-user-name").innerHTML=${talib };</script></c:if>
这里通过jstl形式表达出来,若想拷贝代码测试需要添加<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
阅读全文
0 0
- (项目笔记)<include>与<jsp:param>配合 传值
- 【jsp】<jsp:param/>与<jsp:include/>的配合使用
- <jsp:include page= 与 <jsp:param
- jsp:include 使用jsp:param乱码解决
- jsp:include 使用jsp:param乱码解决
- jsp动作元素介绍 jsp:forward jsp:include jsp:param
- jsp include与include
- <%@ include%>与<jsp:include>
- 回看JSP——include指令与动作、forward动作和param动作
- jsp 中的 <jsp:include> <jsp:param>详解
- [JSP]标准标签、<jsp:include、forward、param、useBean、setProperty、getProperty>
- [JSP]标准标签、<jsp:include、forward、param、useBean、setProperty、getProperty>
- JSP-(session,application),Javabean,Model,Cookie,include指令,forward,param--13
- include与jsp:include区别
- include与jsp:include区别
- jsp:include 与 @include 区别
- include与jsp:include区别
- include与jsp:include区别
- emmet官方语法速查
- 深圳P2P:有了银行存管也不一定安全
- NLTK10《Python自然语言处理》code09 建立基于特征的文法
- Python 字符串大小写转换,值域范围
- 全国环游怎么走----蚁群算法
- (项目笔记)<include>与<jsp:param>配合 传值
- 关于Git管理工具,在从服务器端pull代码时,发生的异常信息如下!
- 剑指Offer-60
- HttpURLConnection从客户端向服务器发送Http请求以及服务器响应全过程解析
- Groovy方法注入
- call,apply,bind的联系与区别
- 关于HTTP和HTTPS的安全问题
- LeeNet分类网络(ImageNet100:top1-73.44%,top5-91.40%,CPU_forward-30ms,model_size-2.7M)
- NMOS管G端电平异常,求解释