struts-标签的使用(二)
来源:互联网 发布:c语言入门经典程序 编辑:程序博客网 时间:2024/05/24 16:16
<%@page import="po.Student,java.util.*"%><%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %><%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html:html lang="true"> <head> <title>MyJsp.jsp</title> </head> <body>这是第一个页面<a href="jsp2.jsp">链接1</a><br><html:link page="/jsp2.jsp">链接2</html:link><br><html:link href="jsp2.jsp">链接3</html:link><br><html:link forward="JSP2">链接4</html:link><html:link action="/xxx.do">链接5(适合链接的同时还作一些操作的情况)</html:link> <hr> <html:link page="/jsp2.jsp?param=0001">到达jsp2,传参数1</html:link><br> <% request.setAttribute("msg", "<b>0001</b>"); // Student stu=new Student(); stu.setUserID("0001"); session.setAttribute("stu", stu); //多个参数可以放入HashMao HashMap<String,String> hm=new HashMap<String,String>(); hm.put("param1", "msg1"); hm.put("param2", "msg2"); hm.put("param3", "msg3"); session.setAttribute("paramList", hm); Cookie c=new Cookie("username","Kate"); c.setMaxAge(1000*60); response.addCookie(c); %> <html:link page="/jsp2.jsp" paramId="param" paramName="msg" >到达jsp2,传参数2</html:link><br> <html:link page="/jsp2.jsp" paramName="stu" paramId="param" paramProperty="userID"></html:link> <html:link page="/jsp2.jsp" name="paramList" >到达jsp2,传参数3</html:link> </body></html:html>
<%@page import="po.Student" %><%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %><%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %><%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html:html lang="true"> <head> <title>jsp2.jsp</title> </head> <body> 获得参数param:<%=request.getParameter("param") %><br> 获得参数param: <bean:parameter name="param" id="str"/> <bean:write name="str" filter="false"/><br> 显示JavaBean内的属性(stu从session内得到):<bean:write name="stu" property="userID"/> Cookie的值:<bean:cookie name="username" id="cookie1"/><bean:write name="cookie1" property="value"/> <!-- 判断str是否等于0001,是就显示"OK" --> <logic:equal name="str" value="0001"> OK </logic:equal> </body></html:html>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<%@ page language="java" pageEncoding="UTF-8"%><%@page import="java.util.*,po.Student" %><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %><%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %><%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html:html lang="true"> <head> <html:base /> <title>jsp3.jsp</title> </head> <body> 这是第三个页面<br> <html:link href="jsp4.jsp">跳转到页面4</html:link> <% //简单集合:集合(数组)里面是i暗淡数据 ArrayList<String> books=new ArrayList<String>(); books.add("三国演义"); books.add("水浒传"); books.add("西游记"); session.setAttribute("books", books); //集合里面含有 JavaBean ArrayList<Student> stus=new ArrayList<Student>(); Student stu1=new Student(); stu1.setUserID("0001"); Student stu2=new Student(); stu2.setUserID("0002"); Student stu3=new Student(); stu3.setUserID("0003"); stus.add(stu1); stus.add(stu2); stus.add(stu3); session.setAttribute("stus", stus); //javaBean里面有集合 Student stu4=new Student(); ArrayList phones=new ArrayList(); phones.add("123123"); phones.add("34534543"); stu4.setPhone(phones); session.setAttribute("stu4", stu4); //复杂契合:以HashMap为代表 HashMap<String,String> hm=new HashMap<String,String>(); hm.put("param1", "msg1"); hm.put("param2", "msg2"); hm.put("param3", "msg3"); session.setAttribute("hm", hm); %> </body></html:html>
<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %><%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %><%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html:html lang="true"> <head> <title>jsp4.jsp</title> </head> <body> 这是第四个页面<br> 简单集合: <logic:iterate id="book" name="books"> <bean:write name="book"/> </logic:iterate><hr> 集合里面含有javaBean <logic:iterate id="stu" name="stus"> <bean:write name="stu" property="userID"/> </logic:iterate><br> JavaBean里有集合: <logic:iterate id="stu_phones" name="stu4" property="phone"> <bean:write name="stu_phones"/> </logic:iterate><br> 遍历HashMap: <logic:iterate id="hm_key" name="hm"> <bean:write name="hm_key" property="value"/> </logic:iterate> </body></html:html>
阅读全文
0 0
- struts-标签的使用(二)
- struts-struts标签的使用(一)
- struts的bean标签(二)
- struts标签的使用
- struts标签的使用
- struts 标签的使用
- Struts1.2开发技巧二-----------------Struts标签的使用
- struts常用标签(包括特殊的表单标签)使用
- 标签的使用(二)
- Struts 常用标签的使用
- Struts使用标签的问题
- struts数据标签的使用
- struts数据标签的使用
- struts的if标签使用
- Struts Logic标签库(二)
- Struts Logic标签库(二)
- struts标签-参数传递测试(二)
- SSH系列(二)struts标签库
- CentOS7环境安装MySQL
- Scala基础入门(十二 ) Scala 模式匹配
- SQL数据库
- Gulp介绍
- 算法题/调整数组顺序使奇数位于偶数前面
- struts-标签的使用(二)
- 树的点分治(HDU 5977 && 2016ICPC大连 G: Garden of Eden)
- 并查集入门--hd 1272 小希的迷宫 并查集判断环
- 牛客网-身份证分组
- nyoj 42一笔画问题
- Java中的String为什么是不可变的? — String源码分析
- 【HDUOJ2063】 过山车(最大匹配数,匈牙利算法,模板题)
- marquee插件水平滚动字幕循环滚动
- Android 通知消息水平播放、无限循环效果实现