<%@ page import ="java.util.*" %>
<%@ page import ="book.*" %>
ArrayList movies = (ArrayList) request.getAttribute("movieinfo");
if(movies!=null){
for(int i=0;i<movies.size();i++){
movie b = (movie) movies.get(i);
out.println("<tr>");
out.println("<td>" + b.getMovieID() + "</td>");
out.println("<td>" + b.getMovieTitle() + "</td>");
out.println("<td>" + b.getReleaseDate() + "</td>");
out.println("<td>" + b.getDescription() + "</td>");
out.println("<td>" + b.getImage() + "</td>");
}
}
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 80 in the jsp file: /index.jsp
movie cannot be resolved to a type
77:
78: if(movies!=null){
79: for(int i=0;i<movies.size();i++){
80: movie b = (movie) movies.get(i);
81: out.println("<tr>");
82: out.println("<td>" + b.getMovieID() + "</td>");
83: out.println("<td>" + b.getMovieTitle() + "</td>");
package movie;
import java.util.Date;
public class movie {
private int MovieID;
private String MovieTitle;
private String Description;
private String Image;
private Date ReleaseDate;
public int getMovieID() {
return MovieID;
}
public void setMovieID(int movieID) {
MovieID = movieID;
}
public String getMovieTitle() {
return MovieTitle;
}
public void setMovieTitle(String movieTitle) {
MovieTitle = movieTitle;
}
public String getDescription() {
return Description;
}
public void setDescription(String description) {
Description = description;
}
public String getImage() {
return Image;
}
public void setImage(String image) {
Image = image;
}
public Date getReleaseDate() {
return ReleaseDate;
}
public void setReleaseDate(Date releaseDate) {
ReleaseDate = releaseDate;
}
}
package movie;
import java.sql.*;
import java.util.ArrayList;
public class MovieDB {
public ArrayList movies (String query){
ArrayList movies= new ArrayList();
try {
// step 1 : load JDBC Driver
Class.forName("com.mysql.jdbc.Driver");
//step2 : define Connection URL
String connURL = "jdbc:mysql://localhost:3306/sp_movie?user=root&password=root";
//step3 establish connection url
Connection conn = DriverManager.getConnection(connURL);
String sql="{call "+query+"}";
CallableStatement cs=conn.prepareCall(sql);
ResultSet rs=cs.executeQuery();
while(rs.next()){
movie movies1 = new movie();
movies1.setMovieID(rs.getInt("Movie_ID"));
movies1.setMovieTitle(rs.getString("Movie_Title"));
movies1.setReleaseDate(rs.getDate("Release_Date"));
movies1.setImage(rs.getString("Image"));
movies1.setDescription(rs.getString("Description"));
movies.add(movies1);
}
} catch (Exception e){
} finally {
try {
} catch (Exception e) {}
}
return movies;
}
}
src/movie/moviesearch.java
package movie;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Moviesearch
*/
@WebServlet("/Moviesearch")
public class Moviesearch extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Moviesearch() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String search = (String) request.getAttribute("search");
String searchtype = (String) request.getAttribute("searchtype");
String query = null;
if (searchtype.equals("title")){
query = "titlesearch('"+search+"')";
}else if(searchtype.equals("genre")){
query = "genresearch('"+search+"')";
}else if(searchtype.equals("actor")){
query = "actorsearch('"+search+"')";
}
ArrayList movies = null;
try{
String userid = request.getParameter("userid");
MovieDB getinfo = new MovieDB();
movies = getinfo.movies(query);
request.setAttribute("movieinfo",movies);
RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
rd.forward(request, response);
} catch (Exception e){
} finally {
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
}
查看movie
类定义。它被打包在movie
包中。
package movie; // full class name will be movie.movie
import java.util.Date;
public class movie { ......
}
您应该将movie
类导入为:
<%@ page import ="movie.movie" %>
即使这样,在JSP中编写Java代码也是非常不受欢迎的。阅读如何避免jsp文件中的Java代码?。
我对JSP是新手。我正在学习useBean方法,在 http://www.studytonight.com/jsp/getproperty-tag.php 我得到了一个错误:在jsp文件中:/hello1的第5行发生了一个错误。jsp PersonBean无法解析为类型
我有一个jsp proyect作为表示层来显示来自java类的函数的结果(一个简单的字符串)。该类位于src目录中。 我没有用Eclipse创建这些类。它们来自另一个项目,但它们都放在src目录中(java类的位置)。jsp似乎无法识别它们。
我试图寻找此错误的解决方案,但仍然无法使用类,因此我尝试手动进行导入,但只能看到三个类、和。 在中查看时,我可以看到文件,在打开JAR时,我还可以看到类pattern.class。 有人能帮助Eclipse为什么看不到这个类吗?
我想在eclipse IDE中使用Java编写1.18.2 Minecraft插件。我很确定我正在使用最新版本。我正在使用教程,当它说要把这个放进去时: 在JavaPlugin下面显示了一条红线,它说它不能被解析为一个类型。我应该导入这个: 导入组织。巴基特。插件。JAVAJavaPlugin 我在谷歌上搜索到的每一句话都把这个插口罐放在了项目属性中
我将selenium与java和以下pom包一起使用, 我可以使用WebDriver和其他对象,但当我试图使用注释@findby时,我的项目似乎找不到满足它的包“不能解析为类型”,也不建议使用selenium包。 selenium的注释系统位于哪个maven存储库中?还是我错过了什么? 谢谢。
这是一个相当基本的程序。当我尝试打印方法和方法时,我会出现错误,表示参数不能解析为变量。 公共类PizzaOutput{ 导入java.util.scanner; 公共类PizzaInput{Scanner键盘=新扫描器(System.in); } 公共级披萨订单{私人最终双份奶酪价格=2.40;