Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > jsp入门教程

jsp基础教程:中正则表达式用法实例

来源:中文源码网    浏览:333 次    日期:2024-03-26 22:28:17
【下载文档:  jsp基础教程:中正则表达式用法实例.txt 】


JSP中正则表达式用法实例
本文实例讲述了JSP中正则表达式用法。分享给大家供大家参考,具体如下:
<%@ page language="java" import="java.util.*,cn.com.Person,cn.com.Adddress" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>




My JSP 'El.jsp' starting page








<%
String data="assd";
request.setAttribute("data", data);
%>

${data }


<%
Person p=new Person();
p.setName("name");
request.setAttribute("person", p);
%>

${person.name}


<%
Person p2=new Person();
Adddress add=new Adddress();
add.setCity("NewYork");
p2.setAddress(add);
request.setAttribute("p2", p2);
%>

${p2.address.city}


<%
ArrayList list=new ArrayList();
list.add(new Person("wy"));
list.add(new Person("wyy"));
list.add(new Person("wyyy"));
request.setAttribute("list", list);
%>

${list[1].name }


<%
Map map=new HashMap();
map.put("1", new Person("aaaa"));
map.put("b", new Person("bbbb"));
map.put("c", new Person("cccc"));
map.put("d", new Person("dddd"));
request.setAttribute("map", map);
%>

${map.b.name}
${map['1'].name }



${pageContext.request.contextPath}



PS:这里再为大家提供2款非常方便的正则表达式工具供大家参考使用:
JavaScript正则表达式在线测试工具:
http://tools.zwyuanma.com/regex/javascript
正则表达式在线生成工具:
http://tools.zwyuanma.com/regex/create_reg
希望本文所述对大家JSP程序设计有所帮助。

相关内容