发布的内容类型不是多部分/表单数据

时间:2018-09-08 07:58:13

标签: jsp

<%
    MultipartRequest m=new MultipartRequest(request,"D:\\Adv.java\\SessionTrackingProcess\\Farmer Scheme Informer\\WebContent\\news",1024*1024*1024);
    String file=m.getFilesystemName("file");
    String des=m.getParameter("description");

        Class.forName("com.mysql.jdbc.Driver");
        Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dbfarm","root","root");
        String query="insert into news (name,pname) values (?,?)";
        PreparedStatement ps=con.prepareStatement(query);
        ps.setString(1,"news/"+file);
        ps.setString(2,des);
    int done=ps.executeUpdate();
    int cnt=1;
    if(done>0)
    {
        out.print("News is added Successfully");
        response.sendRedirect("news.jsp");
        cnt++;
    }
    else
    {
        out.print("News is not added into database");
        response.sendRedirect("news.jsp");
    }
%

0 个答案:

没有答案