JSP页面运行错误User cannot be resolved to a type
HTTPStatus500------------------------------------------------------------------------...
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 compile class for JSP
Generated servlet error:
Only a type can be imported. com.lut.shopping.User resolves to a package
An error occurred at line: 4 in the jsp file: /Shopping/WebContent/register.jsp
Generated servlet error:
User cannot be resolved to a type
An error occurred at line: 4 in the jsp file: /Shopping/WebContent/register.jsp
Generated servlet error:
User cannot be resolved to a type
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
Only a type can be imported. com.lut.shopping.User resolves to a package
An error occurred at line: 4 in the jsp file: /Shopping/WebContent/register.jsp
Generated servlet error:
User cannot be resolved to a type
An error occurred at line: 4 in the jsp file: /Shopping/WebContent/register.jsp
Generated servlet error:
User cannot be resolved to a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.20
以上是错误代码,下面是错误的位置
<%@ page language="java" contentType="text/html; charset=GB18030" import="java.sql.*"
pageEncoding="GB18030"%>
<%@ page import="com.lut.shopping.User" %>
<%
String action = request.getParameter("action");
if(action !=null && action.trim().equals("register")) {
String username = request.getParameter("username");
String password = request.getParameter("password");
String phone = request.getParameter("phone");
String addr = request.getParameter("addr");
User u = new User();
u.setUsername(username);
u.setPassword(password);
u.setAddr(addr);
u.setRdate(new Timestamp(System.currentTimeMillis()));
u.save();
out.println("注册成功");
}
%> 展开
--------------------------------------------------------------------------------
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 compile class for JSP
Generated servlet error:
Only a type can be imported. com.lut.shopping.User resolves to a package
An error occurred at line: 4 in the jsp file: /Shopping/WebContent/register.jsp
Generated servlet error:
User cannot be resolved to a type
An error occurred at line: 4 in the jsp file: /Shopping/WebContent/register.jsp
Generated servlet error:
User cannot be resolved to a type
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
Only a type can be imported. com.lut.shopping.User resolves to a package
An error occurred at line: 4 in the jsp file: /Shopping/WebContent/register.jsp
Generated servlet error:
User cannot be resolved to a type
An error occurred at line: 4 in the jsp file: /Shopping/WebContent/register.jsp
Generated servlet error:
User cannot be resolved to a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.20
以上是错误代码,下面是错误的位置
<%@ page language="java" contentType="text/html; charset=GB18030" import="java.sql.*"
pageEncoding="GB18030"%>
<%@ page import="com.lut.shopping.User" %>
<%
String action = request.getParameter("action");
if(action !=null && action.trim().equals("register")) {
String username = request.getParameter("username");
String password = request.getParameter("password");
String phone = request.getParameter("phone");
String addr = request.getParameter("addr");
User u = new User();
u.setUsername(username);
u.setPassword(password);
u.setAddr(addr);
u.setRdate(new Timestamp(System.currentTimeMillis()));
u.save();
out.println("注册成功");
}
%> 展开
5个回答
展开全部
可能你的User类引用的不对,仔细检查一下你的User类的包名类名对不对。
错误提示貌似是说你的User是个包,而不是一个类,问题应该就在User上好好检查一下
错误提示貌似是说你的User是个包,而不是一个类,问题应该就在User上好好检查一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
u.setRdate-->u.setdate 这个错误估计是打错字了,好好检查检查把。
检查方法:用out.print(变量)追踪各个变量,还要仔细检查写的javabean。
你这个具体错误一下也看不出来,自己好好看看把,祝你好运!
检查方法:用out.print(变量)追踪各个变量,还要仔细检查写的javabean。
你这个具体错误一下也看不出来,自己好好看看把,祝你好运!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<%@ page import="com.lut.shopping.User" %>
检查下路径
检查下路径
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼主的问题解决了吗?我也遇到了相同的问题,求解释啊。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询