当我这样做时,我的servlet会得到空值?它与其他人不同,因为我没有得到任何答案吗?

时间:2018-03-26 07:08:59

标签: jsp servlets

       String store = "";
        String description = request.getParameter("desc");
        System.out.println(description);
        String title = request.getParameter("title");
        System.out.println(title);
    String fileName = request.getParameter("file_name");
        System.out.println(fileName);
        InputStream inputStream = null;
        Part file = request.getPart("file");
        if (file != null) {
            inputStream = file.getInputStream();
        }
        String taskPriority = request.getParameter("priority");
        int priority = Integer.parseInt(taskPriority);
        System.out.println("priority");
        SimpleDateFormat date = new SimpleDateFormat("YYYY-MM-DD");
        Date chosenDate;
        Date endDate;
        try {
            chosenDate = date.parse(request.getParameter("sdate"));
            System.out.println(chosenDate);
            endDate = date.parse(request.getParameter("ddate"));
            System.out.println(endDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        String[] stores = request.getParameterValues("store");
        for (int i = 0; i < stores.length; i++) {
            store += stores[i] + " ";
            System.out.println(store);
        }


    <body>
    <div class="container">
        <form action="create-task" method="post" enctype="multipart/form-data" >
            <div class="form-group">
                <label>TaskId</label><input type="text" name="task_id">  <label>title</label><input
                    type="text" name="title"><label>description</label><input
                    type="text" name="desc"> <label>priority</label> <select
                    class="form-control" type="text" name="priority">
                    <option>Urgent</option>
                    <option>Medium</option>
                    <option>Low</option>
                </select> <label>File</label><input type="file" name="file"> <label>FileName</label><input
                    type="text" name="file_name"> <label>start&nbsp;Date</label><input
                    type="text" name="sdate"> <label>due&nbsp;Date</label><input
                    type="text" name="ddate"> <label>Stores</label> <select
                    name="stores" multiple>
                    <option value="volvo">Volvo</option>
                    <option value="saab">Saab</option>
                </select>
            </div>
            <button class="submit">Save</button>
        </form>
    </div>
</body>




    INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Mar 26, 2018 12:44:22 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Mar 26, 2018 12:44:22 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Mar 26, 2018 12:44:22 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Mar 26, 2018 12:44:22 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4307 ms
null
null
null
Mar 26, 2018 12:44:57 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [CreateTaskServlet] in context with path [/StoreManagement] threw exception
java.lang.NumberFormatException: null
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at com.azilen.storemanagement.controller.CreateTaskServlet.doPost(CreateTaskServlet.java:65)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)


----------

这是我的servlet,它从jsp页面获取空值。请帮助我请帮助我上面的代码为什么我得到这个null.this是我的特定servlet的jsp页面。如果它即将到来它为什么会到来我没有任何理由。这是jsp页面中的控制台错误。

0 个答案:

没有答案