jstl基础代码
来源:互联网 发布:python网络数据采集 编辑:程序博客网 时间:2024/06/16 04:16
- <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
- <%@ page contentType="text/html;charset=utf-8" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <base href="<%=basePath%>">
- <title>My JSP 'MyJsp.jsp' starting page</title>
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
- <meta http-equiv="description" content="This is my page">
- <!--
- <link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css">
- -->
- </head>
- <body>
- This is my JSP page. <br>
- <c:out value="first"/>
- <c:out value="${header['user-agent']}"></c:out><br>
- <c:out value="${p}">default001</c:out><br>
- <c:out value="hellojsp2.0"/><br>
- <c:out value="${2+4}"/><br>
- <c:out value="${param.data}" default="no data"/><br>
- <c:out value="</p>have speical" escapeXml="true"/><br>
- <c:set var="number" value="${1+1}" scope="session"/>
- <c:out value="${number}"/><br>
- ${number}************
- <c:set var="number1" scope="page" >
- (1+1)
- </c:set>
- <c:remove var="number1" scope="page"/>
- <c:out value="${number1}" default="removed"/><br>
- <c:catch var="catchname">
- <%
- String ef="no number";
- int i=Integer.parseInt(ef);
- %>
- </c:catch>
- ${catchname }
- <c:if test="${param.username=='admin'}" var="condition" scope="page">
- (if test)user***admin
- </c:if>
- ${condition }
- <br>
- <c:choose>
- <c:when test="${param.username=='admin'}">
- user****admin
- </c:when>
- <c:when test="${param.username=='superadmin'}">
- user****superadmin
- </c:when>
- <c:otherwise>
- user****no permission
- </c:otherwise>
- </c:choose><br>
- <%
- String[] atts=new String[5];
- for(int i=0;i<atts.length;i++){
- atts[i]="array"+i;
- System.out.println(atts[i]);
- }
- session.setAttribute("arraytest",atts);
- %>
- <c:forEach items="${arraytest}" var="at">
- <c:out value="${at}"/><br>
- </c:forEach>
- <%
- //ArrayList<String> alist = new ArrayList<String>();
- List<String> alist = new ArrayList<String>();
- for(int i=0;i<atts.length;i++){
- alist.add("arraylist"+i);
- }
- session.setAttribute("alist",alist);
- Set<String> settest = new HashSet<String>();
- for(int i=0;i<atts.length;i++){
- settest.add("hashset"+i);
- }
- session.setAttribute("hashset",settest);
- Map<String,String> hashmap = new HashMap<String,String>();
- for(int i=0;i<atts.length;i++){
- hashmap.put("key"+i,"value"+i);
- }
- session.setAttribute("hashmap",hashmap);
- ArrayList<Object> doublearraylist = new ArrayList<Object>();
- for(int i=0;i<atts.length;i++){
- doublearraylist.add(atts);
- }
- session.setAttribute("doublearraylist",doublearraylist);
- ArrayList<Object> doublearraylisthash = new ArrayList<Object>();
- for(int i=0;i<atts.length;i++){
- doublearraylisthash.add(hashmap);
- }
- session.setAttribute("doublearraylisthash",doublearraylisthash);
- //Map<?,?> hashtableproperties = System.getProperties();
- //Set<?> settest2 = hashtableproperties.entrySet();
- //Iterator<?> itror = settest2.iterator();
- //while(itror.hasNext()){
- //String keystr =(String)itror.next();
- //System.out.println("%%%%%%%%%"+keystr);
- //}
- Properties p = new Properties();
- p.setProperty("propertieskey","propertiesvalue");
- session.setAttribute("properties",p);
- %>
- <c:forEach items="${alist}" var="at">
- <c:out value="${at}"/><br>
- </c:forEach>
- <c:forEach items="${hashset}" var="at">
- <c:out value="${at}"/><br>
- </c:forEach>
- <c:forEach items="${hashmap}" var="at">
- <c:out value="${at.key}"/>::::::::<c:out value="${at.value}"/><br>
- </c:forEach>
- --------------double loop start----------<br>
- <c:forEach items="${doublearraylist}" var="at">
- <c:forEach items="${at}" var="at1">
- <c:out value="${at1}"/><br>
- </c:forEach>
- </c:forEach>
- --------------double loop end----------<br>
- --------------double loop hasharraylist start----------<br>
- <c:forEach items="${doublearraylisthash}" var="at">
- <c:forEach items="${at}" var="at1">
- <c:out value="${at1.key}"/>&&&&&&&&&&&&6<c:out value="${at1.value}"/><br>
- </c:forEach>
- </c:forEach>
- --------------double loop hasharraylist end----------<br>
- --------------properties start----------<br>
- <c:forEach items="${properties}" var="at1">
- <c:out value="${at1.key}"/>@@@@@properties@@@@@@@<c:out value="${at1.value}"/><br>
- </c:forEach>
- --------------properties end----------<br>
- --------------step start----------<br>
- <c:forEach items="${arraytest}" var="at1" begin="1" end="4" step="2">
- <c:out value="${at1}"/><br>
- </c:forEach>
- --------------step end----------<br>
- <%
- int[] intarray = new int[10];
- for(int i=0;i<10;i++){
- intarray[i]=i;
- }
- session.setAttribute("intarray",intarray);
- %>
- <c:forEach items="${intarray}" var="item" varStatus="s">
- <c:if test="${s.count%2==0}"><font color="blue"></c:if>
- <c:if test="${s.count%2==1}"><font color="green"></c:if>
- <c:out value="${item}"/>
- index*****<c:out value="${s.index}"/>
- count*****<c:out value="${s.count}"/>
- first*****<c:out value="${s.first}"/>
- last*****<c:out value="${s.last}"/><br>
- </font>
- </c:forEach>
- <%
- //<!--<c:import url="import.txt" var="c" scope="session" />-->
- //<!-- <c:import url="http://www.google.cn/music/homepage">
- //<c:param name="hl" value="zh-CN"></c:param>
- //<c:param name="tab" value="wU"></c:param>
- //</c:import>-->
- //<!-- <c:redirect url="http://java.sun.com" >
- //</c:redirect>-->
- %>
- <c:forTokens items="1,2,5,7,8,56,tytr,;76gh,7,,87" delims="," var="as">
- <c:out value="${as}"></c:out><br>
- </c:forTokens>
- <fmt:formatNumber value="12" pattern="0.00000" ></fmt:formatNumber>
- <jsp:useBean id="now" class="java.util.Date"></jsp:useBean>
- <fmt:formatDate value="${now}" pattern="yyyy-MM-dd" />
- <fmt:setBundle basename="/resources/app" var="app"/>
- <fmt:message key="dbname" bundle="${app}"/>
- <fmt:message key="app.name" bundle="${app}"/>
- <fmt:bundle basename="../resources/app">
- <fmt:message key="app.name" />
- </fmt:bundle>
- <sql:setDataSource
- url="jdbc:postgresql://localhost/mydb"
- driver="org.postgresql.Driver"
- user="postgres"
- password="19810101"
- var="mydatasource"
- scope="session"
- />
- <sql:query var="student" dataSource="${mydatasource}">
- select * from student order by stuno
- </sql:query>
- <table border="1" bordercolor="#cc2211">
- <tr >
- <td>stuno</td>
- <td>stuname</td>
- <td>score</td>
- </tr>
- <c:forEach var="row" items="${student.rows}">
- <tr>
- <td><c:out value="${row.stuno}"/></td>
- <td><c:out value="${row.stuname}"/></td>
- <td><c:out value="${row.stuscore}"/></td>
- </tr>
- </c:forEach>
- </table>
- good
- <c:out value="${fn:length('8886776')}"/>
- <%
- //<c:set var="score" value="90"></c:set>
- ////<c:set var="sno" value="1001"></c:set>
- //// <c:set var="stardate" value="${now}" ></c:set>
- //<sql:transaction dataSource="${mydatasource}">
- //<sql:update>
- //////update student set stuscore=?,startdate=? where stuno=to_number(?,'99999')
- //<sql:param value="${score}"></sql:param>
- //<sql:dateParam value="${stardate}" type="timestamp"></sql:dateParam>
- //<sql:param value="${sno}"></sql:param>
- //</sql:update>
- //</sql:transaction>
- %>
- </body>
- </html>
0 0
- jstl基础代码
- jstl基础代码
- JSTL基础
- jstl基础
- JSTL基础
- JSTL基础篇(一)
- JSTL基础功能
- JSTL和EL基础
- JSTL和EL基础
- 10017---JavaWeb基础--JSTL
- JSP 基础 EL+JSTL
- JSTL 基础详解
- jstl常用代码
- JSTL代码实例
- 第一个JSTL代码
- JSTL实战二之基础
- JSTL学习(很基础)
- JSTL和EL的基础
- Scrollview 嵌套Listview 冲突的解决方法
- Android开发:Android设备传感器开发总结
- .NET 程序美化界面的最佳选择
- 23种设计模式之【简单工厂模式】
- 金额转换——阿拉伯数字的金额转换成中国传统的形式如:(¥1011)->(一千零一拾一元整)
- jstl基础代码
- nyoj49坑爹
- js日期比较
- Pattern:group
- Linux下Nginx如何切割访问日志?
- jsp中jstl标签库里面变量设置基础教程
- 输出变量的字节表示形式
- Linux下gcc编译生成动态链接库*.so文件并调用它
- linux中I/O流中的全缓冲、行缓冲和无缓冲,简明实例演示