This article describes the usage of regular expressions in JSP. Share it for your reference, as follows:
<%@ page language="java" import=".*,," pageEncoding="UTF-8"%> <% String path = (); String basePath = ()+"://"+()+":"+()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My 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=""> --> </head> <body> <% String data="assd"; ("data", data); %> <!-- Regular expressions,for RequestThe data transmitted can be displayed directly as follows Equivalent to:("data"); This is the general way --> ${data } <br/> <% Person p=new Person(); ("name"); ("person", p); %> <!-- reflectionnameAttribute to get this value output Data passedJAVABeanThe following are sent from: --> ${} <br/> <% Person p2=new Person(); Adddress add=new Adddress(); ("NewYork"); (add); ("p2", p2); %> <!-- The following is to define aPersonclass and oneAdddressClass of PersonPrivate attributes:private Adddress address; To obtain his address, you can complete it in the following way The data is complexbeanThe following are brought in: --> ${} <br/> <% ArrayList list=new ArrayList(); (new Person("wy")); (new Person("wyy")); (new Person("wyyy")); ("list", list); %> <!-- How to get data from the collection? --> ${list[1].name } <br/> <% Map map=new HashMap(); ("1", new Person("aaaa")); ("b", new Person("bbbb")); ("c", new Person("cccc")); ("d", new Person("dddd")); ("map", map); %> <!-- MapHow to get data from the collection? mapWhen the collection of data is storedidDo not use numbers generally:Will appear500mistake But if you use numbers, you can get it in the second .If you can't get the number out, use brackets[] --> ${} ${map['1'].name } <br/> <!-- Get the current onewebProject name --> ${} <a href="${}/" >point</a> </body> </html>
PS: Here are two very convenient regular expression tools for your reference:
JavaScript regular expression online testing tool:
http://tools./regex/javascript
Regular expression online generation tool:
http://tools./regex/create_reg
I hope this article will be helpful to everyone's JSP programming.