1个回答
展开全部
应该是把java代码嵌入到 html 中 jsp: <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% 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 'buy.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"> --> </head> <body> <% request.setCharacterEncoding("utf-8"); String productName=request.getParameter("productName"); int productNum=Integer.parseInt("productNum"); Object obj=session.getAttribute(productName); if(obj!=null){ int oldNum=((Integer)obj).intValue(); productNum+=oldNum; session.setAttribute(productName, productNum); }else{ session.setAttribute(productName, productNum); } %> 购物成功 <a href="show.jsp">查看购物车</a> <a href="index.jsp">继续购物</a> <% %> </body> </html> 不能实现功能哈 只是给你看看结构
希望采纳
希望采纳
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |