jsp专辑可以解析为一种类型

时间:2015-11-03 23:38:37

标签: java sql jsp

我确信我已将相册放入我的包装中,但仍然存在此错误:

org.apache.jasper.JasperException:无法为JSP编译类

jsp文件中的第38行:/albums.jsp发生错误 生成的servlet错误: 相册无法解析为类型

jsp文件中的第38行:/albums.jsp发生错误 生成的servlet错误: 相册无法解析为类型

jsp文件中的第38行:/albums.jsp发生错误 生成的servlet错误: 复制本地变量相册

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
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)
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="photoshare.NewUserDao" %>
<jsp:useBean id="newUserBean"
class="photoshare.NewUserBean" />
<jsp:setProperty name="newUserBean" property="*"/>

<%@ page import="photoshare.NewAlbumDao" %>
<jsp:useBean id="album"
         class="photoshare.Album" />

<html>
<head><title>Album and Pictures</title></head>
 <body>
<h2>Create a New Album </h2>
<form action="/photoshare/createalbum.jsp?NewAlbumName=" target="_blank" method="get">
  Album Name: <input type="text" name="NewAlbumName"/>
  <input type="submit" value="Create"/><br/>
</form>
<h2>Your Albums</h2>
<tr>
<%
NewUserDao newUserDao = new NewUserDao();
NewAlbumDao newAlbumDao = new NewAlbumDao();
String owner_email = request.getUserPrincipal().getName();
int owner_id = newUserDao.getUserID(owner_email);
List<String> albumName = new ArrayList<String>();
albumName = newAlbumDao.getYourAlbumsName(owner_id);
List<album> albumList = new ArrayList<album>();
albumList = newAlbumDao.getYourAlbums(owner_id);
for (String album:albumList) {%>
    <a href="yourAlbum.jsp?album_id=<%= album.getAlbumID() %> & album_name= <%= album.getName()%>"> <%= album.getName()%></a></br>
<%}%>
</tr>
<h4>Return to<a href="index.jsp">Home</a></h4>
</body>
</html>

当我重新启动tomcat服务时似乎没有用,谢谢你回答!!!

1 个答案:

答案 0 :(得分:0)

请看一下:

List<album> albumList = new ArrayList<album>();

专辑已在JSP中定义为bean。但是,在List定义中,您需要提供类名。

我相信您需要将此行更改为:

List<photoshare.Album> albumList = new ArrayList<photoshare.Album>();