我正在尝试存储一个文件以及在数据库中的文本字段(orderid2和remarks)中输入的另外两个值。但是,列表< FileItem>一片空白。我不知道我的代码有什么问题。它没有进行public class Circle extends Shape{
private double radius=1;
private final double PI = Math.PI;
private Scanner get = new Scanner(System.in);
public Circle(double radius){
super("Circle");
this.radius = radius;
}
public Circle(){
super("Circle");
String help;
do{
System.out.print("Write radius: ");
help = get.nextLine();
}while(Cnauka.isDouble(help) == false);
this.radius = Double.parseDouble(help);
}
@Override
public double area(){
return radius * radius * PI;
}}
循环。
while
P.S。
我实际上认为问题出在request变量中。我在这个函数DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List<FileItem> items = upload.parseRequest(request);
Iterator<FileItem> iter = items.iterator();
while(iter.hasNext()) {
FileItem item = iter.next();
if(item.isFormField()) {
String name = item.getFieldName();
String value = item.getString();
System.out.println(name + " " + value);
if(name.equals("orderid2"))
order.setOrderID(Integer.parseInt(value));
else if(name.equals("remarks"))
order.setRemarks(value);
}
}
中的servlet中有这整个代码
我真的不知道protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, FileUploadException, SQLException {
的参数应该是什么。我只是把它复制到了某个地方