JSP 分割字符串实现换行
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.StringTokenizer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="html/css">
<!--
.STYLE1{
font-size:large;
}
-->
</style>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String str1=request.getParameter("str1");
if(str1==null)
str1="";
String str2=request.getParameter("str2");
if(str2==null)
str2="";
%>
<form name="form1" action="stringtoken.jsp" method="post">
<div class="STYLE1">分割字符串实现换行</div>
待分割字符串<input type="text" name="str1" value="<%=str1 %>"/>
<br />
分隔字符集合<input type="text" name="str2" value+"<%=str2 %>"/>
<br />
<input name="ok" type="submit" value="提交">
</form>
<p>
<%
StringTokenizer st=new StringTokenizer(str1,str2);
while(st.hasMoreTokens()){
String tmp=st.nextToken();
out.print(tmp);
out.print("<br/>");
}
%>
</p>
</body>
</html>