'JavaWeb can`t get the value of hidden in the form

Recently,I want to implement a function of upload At first,I extracted a abstract class --BaseServlet as follows:

public abstract class BaseServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        String action = req.getParameter("action");
       //I can`t get the value of action here.

        try {
            Method method = this.getClass().getDeclaredMethod(action,HttpServletRequest.class,HttpServletResponse.class);
            method.invoke(this,req,resp);
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}

The html page is following:

<form class="form-horizontal" id="upload" method="post" action="/fileServlet" enctype="multipart/form-data">
        <input type="hidden" name="action" value="uploadFile">
        <div class="form-group" align="center">
            <div class="col-md-4 col-sm-4  col-xs-4 col-lg-4">
                title<input type="text" name="title" id="title"><br>
                videoUpload<input type="file" accept="video/mp4" name="video" id="video"><br>
                videoCover<input type="file" name="picture" id="cover" accept="image/png,image/jpeg"><br>
                videoIntroduce
                <textarea id="self" name="self" style="height: 50px;width: 200px"></textarea><br>
                <input type="submit" name="sub_btn" value="sub_confirm">
            </div>
        </div>
    </form>

I still can't get this value by commenting out the js code. I would appreciate it if anyone could help me.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source