当前位置:编程学习 > JSP >>

JSP的留言板一段代码实在是把我逼疯了,求高手,只有10分全部奉上!先说声谢谢了!

完全是照着书来打的就是不对! 500错误:An error occurred at line: 7 in the generated java file Only a type can be imported. javax.resource.spi.ApplicationServerInternalException resolves ———————————— <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <form action="message.jsp" method="post" name="form"> 名字:<br><input type="text" name="pname"> <br>留言标题<input type="text" name="biaoti"> 留言:<br><textarea rows="10" cols="36" name="liuyan" wrap="phisical"></textarea> <br><input type="submit" value="提交信息" name="submit"> </form> <form action="showmessage.jsp" method="post" name="form1"> <input type="submit" value="查看留言板" name="look"> </form> </body> </html> ———————————————————————— <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.util.*"%> <html> <body> <%! Vector v=new Vector(); int i=0; ServletContext application; synchronized void sendMessage(String s) { application=getServletContext(); i++; v.add("No."+i+","+s); application.setAttribute("Mess",v); } %> <% request.setCharacterEncoding("UTF-8"); String name=request.getParameter("pname"); String title=request.getParameter("biaoti"); String message=request.getParameter("liuyan"); if(name==null||name.length()==0) { name="guest"+(int)(Math.random()*10000); } if(title==null) { title="无标题"; } if(message==null) { message="无留言"; } String s="姓名"+name+"#"+"标题"+title+"#"+"内容"+"<br>"+message; sendMessage(s); out.print("您的信息已经提交!"); %> <a href="submit.jsp">返回</a> </body> </html> ———————————————————————————— <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.util.*"%> <html> <body> <% request.setCharacterEncoding("UTF-8"); Vector v=(Vector)application.getAttribute("Mess"); for(int i=0;i<v.size();i++) { String message=(String)v.elementAt(i); StringTokenizer fenxi=new StringTokenizer(message,"#"); while(fenxi.hasMoreTokens()) {String str=fenxi.nextToken(); out.print(str+"<br>"); } } %> </body> </html>
答案:这种错误只有你自己在环境下调试了,你贴上来代码没什么意义,我没有你的环境也不能替你调试,错误信息已经给你指名位置,你仔细查看一下,还有,展现逻辑最好用JSP标签实现,这种写法太乱了,你也不好调试

上一个:基于WEB 的网络办公系统,毕业设计,谁有,发我邮箱1327964536@qq.com JSP 的 有设计跟代码,给至少50财富
下一个:求教JSP源代码的部署方法,急急急!!

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,