hello.jsp,bi.jsp保存在相同的Web服务目录中。以下( )正确。Hello.jsp
<%@ page contentType = "text/html" %>
<%@ page pageEncoding = "utf-8" %>
<HTML><body bgcolor=cyan>
<% String str = "红烧肉:89.8元,麻辣豆腐:21.22元";
%><jsp:forward page="bill.jsp" >
<jsp:param name='bill' value="<%= str %>" />
</jsp:forward>
<h1>欢迎再次光临</h1>
</body></HTML>
bill.jsp
<%@ page contentType="text/html" %>
<%@ page pageEncoding = "utf-8" %>
<%@ page import = "java.util.regex.*"%>
<% Stringstr=request.getParameter("bill");
String regex = "[1-9][0-9]*[\\.]?[0-9]*";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(str);
double sum = 0;
while(m.find()) {
sum = sum+Double.parseDouble(m.group());
}
String result = String.format("%.2f",sum);
%>
<%= result %>