How to determine if a parameter has been “posted” or “geted” from Java?

前端 未结 7 1680
离开以前
离开以前 2021-01-02 04:32

In ASP, there\'s request.form and request.queryString attributes, but in Java. It seems like we have only one collection, which can be accessed via

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-02 04:57

    You can use request.getMethod() to get any Method. I am using HandlerInterceptor for this.

    check this code:

    public class LoggingMethodInterceptor implements HandlerInterceptor {
    
    Logger log = LoggerFactory.getLogger(LoggingMethodInterceptor.class);
    
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        log.info("[START]  [" + request.getMethod() + "] [" + request.getRequestURL() + "] StartTime: {} milliseconds",
                System.currentTimeMillis());
        return true;
    }
    

提交回复
热议问题