1

我正在尝试执行一个 jsp/servlet 程序,但我遇到了问题。请帮忙!:(

这是我得到的错误:Movie 类型中的方法 setReleasedate(Calendar) 不适用于参数 (Date)

这是我的代码:(Servlet)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="com.ServiceProxy"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <%@ page import="entity.Movie" %>
 <%@ page import="java.util.*" %>
 <%@ page import="java.text.SimpleDateFormat" %>
  <%@ page import="java.text.DateFormat" %>
    <%@ page import="java.util.Calendar"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Demo</title>
</head>
<%
Movie m= new Movie();
String mname=request.getParameter("MName");
String mbanner=request.getParameter("Mbanner");
String rdate=request.getParameter("Rdate");
String cat=request.getParameter("Cat");

ServiceProxy proxy=new ServiceProxy();
proxy.setEndpoint("http://localhost:8080/VideoLibraryServers/services/Service");

int flag=0;
DateFormat dateFormat;
dateFormat = new SimpleDateFormat("dd-MMM-yy"); 
Date convertedDate;
convertedDate =(Date)dateFormat.parse(rdate);
m.setMoviename(mname);
m.setMoviebanner(mbanner);
m.setReleasedate(convertedDate); // **HERE I GET ERROR!!!!**
System.out.println(m.getReleasedate());
m.setCategory(cat);
flag=proxy.createMovie(m);
if(flag==2)
{
    String error="User with the email already exists";
    session.setAttribute("error",error);
    response.sendRedirect("Signuperror.jsp");
}
else if(flag==1)
{

   response.sendRedirect("MovieAddSucc.jsp");
}
else if(flag==0)
{
    String msg="Adding Movie was UnSuccessful";
    session.setAttribute("ErrMsg",msg);
        response.sendRedirect("ErrMsg.jsp");
}
%>
<body>
</body>
</html>

电影(Java Bean)

import java.util.Date;
public class Movie{
        private int movieid;
        private String moviename;
        private String moviebanner;
        private Date releasedate;
        private int rentamount;
        private String category;
        private int availablecopies;
        public Movie(){
            movieid=0;
            moviename="";
            moviebanner="";
            releasedate=new Date();
            rentamount=0;
            category="";
            availablecopies=0;  
        }
        public int getMovieid() {
            return movieid;
        }
        public void setMovieid(int movieid) {
            this.movieid = movieid;
        }
        public String getMoviename() {
            return moviename;
        }
        public void setMoviename(String moviename) {
            this.moviename = moviename;
        }
        public String getMoviebanner() {
            return moviebanner;
        }
        public void setMoviebanner(String moviebanner) {
            this.moviebanner = moviebanner;
        }
        public Date getReleasedate() {
            return releasedate;
        }
        public void setReleasedate(Date releasedate) {
            this.releasedate = releasedate;
        }
        public int getRentamount() {
            return rentamount;
        }
        public void setRentamount(int rentamount) {
            this.rentamount = rentamount;
        }
        public String getCategory() {
            return category;
        }
        public void setCategory(String category) {
            this.category = category;
        }
        public int getAvailablecopies() {
            return availablecopies;
        }
        public void setAvailablecopies(int availablecopies) {
            this.availablecopies = availablecopies;
        }
}

请帮忙!

4

0 回答 0