刚学的struts,这.jsp文件总运行不起来!很郁闷!高手快帮我看看
我用的是MyEclipse,原文件如下(Register.jsp):
<%@ page language= "java " import= "java.util.* " pageEncoding= "gbk "%>
<%@ taglib uri= "WEB-INF/struts-html.tld " prefix= "html "%>
<%
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 'index.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>
<html:form action= "Registor.do ">
rUsername <html:form type= "text " property= "username "/> <br>
enter password <html:form type= "password " property= "password1 "/> <br>
re-enter password <html:form type= "password " property= "password1 "/> <br>
<html:form type= "submit " value= "Register "/>
</body>
</html:form>
显示的错误是:
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:599)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:141)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.ClassNotFoundException: org.apache.jsp.Register_jsp
java.net.URLClassLoader$1.run(URLClassLoader.java:200)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:188)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:597)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:141)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
--------------------------------------------
Apache Tomcat/5.5.23
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /Register.jsp(26,12) According to the TLD or the tag file, attribute action is mandatory for tag form
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:689)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1442)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2214)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:726)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1442)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2214)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2220)
org.apache.jasper.compiler.Node$Root.accept(Node.java:457)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Validator.validate(Validator.java:1484)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:167)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
--------------------------------------------
Apache Tomcat/5.5.23
------解决方案--------------------
UP
[解决办法]
<html:form action= "Registor.do ">
rUsername <html:form type= "text " property= "username "/> <br>
enter password <html:form type= "password " property= "password1 "/> <br>
re-enter password <html:form type= "password " property= "password1 "/> <br>
<html:form type= "submit " value= "Register "/>
改成:
<html:form action= "/Registor " method= "post ">
enter username: <html:text property= "username "/> <br>
enter password: <html:password property= "password1 "/> <br>
re-enter password: <html:password property= "password1 "/> <br>
<html:submit> Register </html:submit>
另外,你的 struts-config.xml 也必须配置 action 的 path 为“/Registor”。
[解决办法]
应该是标签错了,看看入门的书,struts的标签是怎么用的,
[解决办法]
你的标签写的有错误! rUsername后面应该是 <html:text property= "username "/> 而你写成了form。
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html