/**
   * Initialize logback, including setting the web app root system property.
   *
   * @param servletContext the current ServletContext
   * @see WebUtils#setWebAppRootSystemProperty
   */
  public static void initLogging(ServletContext servletContext) {
    // Expose the web app root system property.
    if (exposeWebAppRoot(servletContext)) {
      WebUtils.setWebAppRootSystemProperty(servletContext);
    }

    // Only perform custom logback initialization in case of a config file.
    String location = servletContext.getInitParameter(CONFIG_LOCATION_PARAM);
    if (location != null) {
      // Perform actual logback initialization; else rely on logback's default initialization.
      try {
        // Return a URL (e.g. "classpath:" or "file:") as-is;
        // consider a plain file path as relative to the web application root directory.
        if (!ResourceUtils.isUrl(location)) {
          // Resolve system property placeholders before resolving real path.
          location = SystemPropertyUtils.resolvePlaceholders(location);
          location = WebUtils.getRealPath(servletContext, location);
        }

        // Write log message to server log.
        servletContext.log("Initializing logback from [" + location + "]");

        // Initialize without refresh check, i.e. without logback's watchdog thread.
        LogbackConfigurer.initLogging(location);

      } catch (FileNotFoundException ex) {
        throw new IllegalArgumentException(
            "Invalid 'logbackConfigLocation' parameter: " + ex.getMessage());
      }
    }
  }
  /**
   * Initialize this context with the given request, using the given model attributes for Errors
   * retrieval.
   *
   * <p>Delegates to {@code getFallbackLocale} and {@code getFallbackTheme} for determining the
   * fallback locale and theme, respectively, if no LocaleResolver and/or ThemeResolver can be found
   * in the request.
   *
   * @param request current HTTP request
   * @param servletContext the servlet context of the web application (can be {@code null};
   *     necessary for fallback to root WebApplicationContext)
   * @param model the model attributes for the current view (can be {@code null}, using the request
   *     attributes for Errors retrieval)
   * @see #getFallbackLocale
   * @see #getFallbackTheme
   * @see org.springframework.web.servlet.DispatcherServlet#LOCALE_RESOLVER_ATTRIBUTE
   * @see org.springframework.web.servlet.DispatcherServlet#THEME_RESOLVER_ATTRIBUTE
   */
  protected void initContext(
      HttpServletRequest request,
      HttpServletResponse response,
      ServletContext servletContext,
      Map<String, Object> model) {

    this.request = request;
    this.response = response;
    this.model = model;

    // Fetch WebApplicationContext, either from DispatcherServlet or the root context.
    // ServletContext needs to be specified to be able to fall back to the root context!
    this.webApplicationContext =
        (WebApplicationContext) request.getAttribute(WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    if (this.webApplicationContext == null) {
      this.webApplicationContext =
          RequestContextUtils.getWebApplicationContext(request, servletContext);
    }

    // Determine locale to use for this RequestContext.
    LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
    if (localeResolver instanceof LocaleContextResolver) {
      LocaleContext localeContext =
          ((LocaleContextResolver) localeResolver).resolveLocaleContext(request);
      this.locale = localeContext.getLocale();
      if (localeContext instanceof TimeZoneAwareLocaleContext) {
        this.timeZone = ((TimeZoneAwareLocaleContext) localeContext).getTimeZone();
      }
    } else if (localeResolver != null) {
      // Try LocaleResolver (we're within a DispatcherServlet request).
      this.locale = localeResolver.resolveLocale(request);
    }

    // Try JSTL fallbacks if necessary.
    if (this.locale == null) {
      this.locale = getFallbackLocale();
    }
    if (this.timeZone == null) {
      this.timeZone = getFallbackTimeZone();
    }

    // Determine default HTML escape setting from the "defaultHtmlEscape"
    // context-param in web.xml, if any.
    this.defaultHtmlEscape =
        WebUtils.getDefaultHtmlEscape(this.webApplicationContext.getServletContext());

    // Determine response-encoded HTML escape setting from the "responseEncodedHtmlEscape"
    // context-param in web.xml, if any.
    this.responseEncodedHtmlEscape =
        WebUtils.getResponseEncodedHtmlEscape(this.webApplicationContext.getServletContext());

    this.urlPathHelper = new UrlPathHelper();

    if (this.webApplicationContext.containsBean(REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME)) {
      this.requestDataValueProcessor =
          this.webApplicationContext.getBean(
              REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME, RequestDataValueProcessor.class);
    }
  }
Exemple #3
0
 @RequestMapping(value = "/action/logout")
 public ModelAndView getActionLogout(HttpServletRequest request, HttpServletResponse response) {
   ModelAndView mv = new ModelAndView("redirect:/webpage/admin");
   WebUtils.setSessionAttribute(request, "user", null);
   WebUtils.setSessionAttribute(request, "member", null);
   SessionUtil.getInstance().saveUserCookie(null);
   SessionUtil.getInstance().saveMemberCookie(null);
   return mv;
 }
 private void storeRequestInSession(HttpServletRequest request) {
   String requestURI = request.getRequestURI();
   String requestedAction = requestURI.substring(requestURI.lastIndexOf("/") + 1);
   WebUtils.setSessionAttribute(request, "requestedAction", requestedAction);
   logger.debug("requestedAction: " + requestedAction);
   WebUtils.setSessionAttribute(
       request, "requestedActionParameterMap", WebUtils.getParametersStartingWith(request, null));
   logger.debug("Map size: " + String.valueOf(request.getParameterMap().size()));
 }
Exemple #5
0
 // 负责注册的请求
 @RequestMapping(value = "/register.html")
 public ModelAndView setLogout(HttpServletRequest request) {
   String name = WebUtils.findParameterValue(request, "inputMail");
   String pwd = WebUtils.findParameterValue(request, "inputPassword1");
   String email = name;
   int type = UserType.CONSUMER_USER;
   User u = new User();
   u.setEmail(email);
   u.setName(name);
   u.setPwd(MD5Util.stringMD5(pwd));
   u.setType(type);
   u.setState(ShopState.LIVE);
   userService.addNewUser(u);
   return new ModelAndView("UserDetail");
 }
 public Map<?, ?> resolve(Invocation inv, ParamMetaData metaData) {
   if (StringUtils.isNotEmpty(metaData.getParamName())) {
     Class<?>[] genericTypes = (Class[]) metaData.getUserObject(this);
     Class<?> keyType = genericTypes[0];
     Class<?> valueType = genericTypes[1];
     Map<?, ?> toConvert =
         WebUtils.getParametersStartingWith(
             inv.getRequest(), metaData.getParamName() + MAP_SEPARATOR);
     if (toConvert != null) {
       if (keyType != String.class || valueType != String.class) {
         Map<Object, Object> ret = new HashMap<Object, Object>();
         for (Map.Entry<?, ?> entry : toConvert.entrySet()) {
           Object key = entry.getKey();
           Object value = entry.getValue();
           TypeConverter typeConverter = SafedTypeConverterFactory.getCurrentConverter();
           if (keyType != String.class) {
             key = typeConverter.convertIfNecessary(key, keyType);
           }
           if (valueType != String.class) {
             value = typeConverter.convertIfNecessary(value, valueType);
           }
           ret.put(key, value);
         }
         return ret;
       }
       return toConvert;
     }
   }
   return new HashMap<Object, Object>(2);
 }
  @ModelAttribute
  public void frontUrl(ModelMap model, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    // model.addAttribute("frontUrl", request.getContextPath() + "/resources");
    userLoad(model);
    model.addAttribute("frontUrl", request.getContextPath() + "/resources");
    // System.out.println("xDamsController.frontUrl() multiAccount: " + multiAccount);
    // System.out.println("xDamsController.frontUrl() model.get(\"userBean\"): " +
    // model.get("userBean"));
    if (multiAccount && model.get("userBean") != null) {
      model.addAttribute(
          "frontUrl",
          request.getContextPath()
              + "/resources/"
              + ((UserBean) model.get("userBean")).getAccountRef());
    }

    // System.out.println("xDamsController.frontUrl() model.get(\"frontUrl\"): " +
    // model.get("frontUrl"));
    model.addAttribute("contextPath", request.getContextPath());
    String userAgent = ((HttpServletRequest) request).getHeader("User-Agent");
    if (userAgent.toLowerCase().contains("msie")) {
      response.addHeader("X-UA-Compatible", "IE=edge");
    }

    try {
      Locale locale = RequestContextUtils.getLocale(request);
      ((UserBean) model.get("userBean")).setLanguage(locale.getLanguage());
    } catch (Exception e) {
      // TODO: handle exception
    }
    model.put("realPath", WebUtils.getRealPath(servletContext, ""));
  }
 @Override
 protected String getText(
     final Arguments arguments, final Element element, final String attributeName) {
   final String attributeValue = element.getAttributeValue(attributeName);
   Money price = null;
   Object result = StandardExpressionProcessor.processExpression(arguments, attributeValue);
   if (result instanceof Money) {
     price = (Money) result;
   } else if (result instanceof BigDecimal) {
     price = new Money((BigDecimal) result);
   } else if (result == null) {
     price = Money.ZERO;
   } else {
     throw new IllegalArgumentException("Input is not of type Money or BigDecimal");
   }
   HttpServletRequest curRequest =
       ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
   Locale curLocale =
       (Locale)
           WebUtils.getSessionAttribute(
               curRequest, SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME);
   curLocale = (curLocale == null) ? Locale.US : curLocale;
   NumberFormat format = NumberFormat.getCurrencyInstance(curLocale);
   format.setCurrency(price.getCurrency());
   return format.format(price.getAmount());
 }
  @Override
  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    // Long orderId  = (Long) WebUtils.getRequiredSessionAttribute(request, "orderId");
    int orderId = Integer.parseInt(request.getParameter("orderId"));
    Order order = this.orderService.getOrderById(orderId);

    UserSession userSession =
        (UserSession) WebUtils.getRequiredSessionAttribute(request, "userSession");

    if (userSession.getUser().getUsername().equals(order.getUser().getUsername())) {
      String message = request.getParameter("message");

      Map<String, Object> model = new HashMap<String, Object>();
      model.put("order", order);

      if (message != null) {
        // after the new order, there's thanks message
        model.put("message", message);
      }
      return new ModelAndView("ViewOrder", model);
    } else {
      return new ModelAndView("ValidationError", "message", "You may only view your own orders.");
    }
  }
  @RequestMapping(value = "login", method = RequestMethod.POST)
  ResponseEntity<PageDto> login(
      @Validated @RequestBody LoginDto loginDto,
      HttpServletRequest request,
      HttpServletResponse response) {

    PageDto pageDto = userService.login(loginDto);

    if (pageDto.getHeaderDto().isAuth()) {
      CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class.getName());
      if (csrf != null) {
        Cookie cookie = WebUtils.getCookie(request, "XSRF-TOKEN");
        String token = csrf.getToken();
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if ((cookie == null || token != null && !token.equals(cookie.getValue()))
            && (authentication != null && authentication.isAuthenticated())) {
          cookie = new Cookie("XSRF-TOKEN", token);
          cookie.setPath("/");
          response.addCookie(cookie);
        }
      }
      return new ResponseEntity<>(pageDto, null, HttpStatus.OK);
    } else {
      return new ResponseEntity<>(pageDto, null, HttpStatus.UNAUTHORIZED);
    }
  }
 public ModelAndView summaryList(
     HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse)
     throws Exception {
   this.logger.debug("entering 'summaryList' method...");
   VoucherService localVoucherService = (VoucherService) SysData.getBean("f_voucherService");
   ViewService localViewService = (ViewService) SysData.getBean("f_viewService");
   List localList1 = localViewService.getTrademoduleList();
   List localList2 = localViewService.getLedgerFieldList();
   QueryConditions localQueryConditions =
       QueryHelper.getQueryConditionsFromRequest(paramHttpServletRequest);
   PageInfo localPageInfo = QueryHelper.getPageInfoFromRequest(paramHttpServletRequest);
   if (localPageInfo == null) {
     localPageInfo = new PageInfo(1, 15, "summaryNo", false);
   }
   List localList3 = localVoucherService.getSummarys(localQueryConditions, localPageInfo);
   String str = paramHttpServletRequest.getParameter("targetView");
   if (str == null) {
     str = "voucher/listSummary";
   }
   Map localMap = WebUtils.getParametersStartingWith(paramHttpServletRequest, "_");
   ModelAndView localModelAndView = new ModelAndView("finance/" + str, "resultList", localList3);
   localModelAndView.addObject("pageInfo", localPageInfo);
   localModelAndView.addObject("oldParams", localMap);
   localModelAndView.addObject("fieldList", localList2);
   localModelAndView.addObject("moduleList", localList1);
   return localModelAndView;
 }
  /**
   * 【模板】新闻列表(按时间排序,最新的在最前面)
   *
   * @param request
   * @param response
   * @return
   */
  @SuppressWarnings({"rawtypes", "unchecked"})
  @RequestMapping("/getNewsList")
  public ModelAndView getNewsList(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView mv = new ModelAndView();

    // 绑定request中请求过来的分页参数
    Page page = new Page();
    this.dataBinder(page, WebUtils.getParametersStartingWith(request, ""));

    // 新闻分类ID
    String newsTypeId = request.getParameter("newsTypeId");
    //		log.debug("$$$@@:newsTypeId的值为:"+newsTypeId );
    if (null == newsTypeId || "".equals(newsTypeId)) {
      newsTypeId = INewsService.NEWS_TYPE_ID_ALL;
      //			log.debug("$$$@@:newsTypeId isEmpty!" );
    }

    // 最新新闻
    List<News> news = newsService.findLatestNews(newsTypeId, page.getPageNum(), page.getPageSize());
    PageInfo newsInfo = new PageInfo(news);
    mv.addObject("news", newsInfo);

    log.debug("run newsList:[newsTypeId:" + newsTypeId + "]");
    log.debug("run newsList ......");

    mv.setViewName("/front/modules/newsList");
    return mv;
  }
 public static void setUserSession(HttpServletRequest request, String propertyName, Object obj) {
   UserSession gus = (UserSession) WebUtils.getSessionAttribute(request, Constant.SESS_USER);
   if (propertyName.equals(PROPERTY_USER)) gus.setUser((User) obj);
   else if (propertyName.equals(PROPERTY_LOGIN)) gus.setLogin((Integer) obj);
   else if (propertyName.equals(PROPERTY_BOX_LIST)) gus.setBoxList((List) obj);
   else if (propertyName.equals(PROPERTY_SEARCH)) gus.setSearchKey((String) obj);
 }
  private Object processRemotingRequest(
      HttpServletRequest request,
      HttpServletResponse response,
      Locale locale,
      ExtDirectRequest directRequest,
      MethodInfo methodInfo)
      throws Exception {

    Object[] parameters =
        configurationService
            .getParametersResolver()
            .resolveParameters(request, response, locale, directRequest, methodInfo);

    if (configurationService.getConfiguration().isSynchronizeOnSession()
        || methodInfo.isSynchronizeOnSession()) {
      HttpSession session = request.getSession(false);
      if (session != null) {
        Object mutex = WebUtils.getSessionMutex(session);
        synchronized (mutex) {
          return ExtDirectSpringUtil.invoke(
              configurationService.getApplicationContext(),
              directRequest.getAction(),
              methodInfo,
              parameters);
        }
      }
    }

    return ExtDirectSpringUtil.invoke(
        configurationService.getApplicationContext(),
        directRequest.getAction(),
        methodInfo,
        parameters);
  }
 private Integer getMillisOffset(HttpServletRequest request) {
   Cookie cookie = WebUtils.getCookie(request, "Greenhouse.timeZoneOffset");
   if (cookie != null) {
     return Integer.valueOf(cookie.getValue());
   } else {
     return null;
   }
 }
 public static Object getUserSession(HttpServletRequest request, String propertyName) {
   UserSession gus = (UserSession) WebUtils.getSessionAttribute(request, Constant.SESS_USER);
   if (gus != null && propertyName.equals(PROPERTY_USER)) return gus.getUser();
   else if (gus != null && propertyName.equals(PROPERTY_LOGIN)) return gus.getLogin();
   else if (gus != null && propertyName.equals(PROPERTY_BOX_LIST)) return gus.getBoxList();
   else if (gus != null && propertyName.equals(PROPERTY_SEARCH)) return gus.getSearchKey();
   return null;
 }
 @RequestMapping(value = "/handle22")
 public ModelAndView handle22(HttpServletRequest request) {
   String userName = WebUtils.findParameterValue(request, "userName");
   ModelAndView mav = new ModelAndView();
   mav.setViewName("success");
   mav.addObject("userName", userName);
   return mav;
 }
 protected Object formBackingObject(HttpServletRequest request) throws Exception {
   UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
   if (userSession != null) {
     return new AccountForm(this.petStore.getAccount(userSession.getAccount().getUsername()));
   } else {
     return new AccountForm();
   }
 }
 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
     throws Exception {
   UserSession userSession =
       (UserSession) WebUtils.getRequiredSessionAttribute(request, "userSession");
   String username = userSession.getAccount().getUsername();
   Map model = new HashMap();
   model.put("orderList", this.petStore.getOrdersByUsername(username));
   return new ModelAndView("ListOrders", model);
 }
 public MySession getMySession() {
   MySession mySession = (MySession) WebUtils.getSessionAttribute(getRequest(), "MySession");
   if (mySession != null) {
     return mySession;
   } else {
     showMessage2("页面长时间不活动,已推出", "/login.jsp");
     return null;
   }
 }
Exemple #21
0
 private boolean supportWebp(HttpServletRequest request, String name) {
   Cookie cookie = WebUtils.getCookie(request, WEBP_SUPPORT_COOKIE);
   if (cookie != null && "true".equalsIgnoreCase(cookie.getValue())) {
     String ext = Files.getFileExtension(name);
     return "jpg".equalsIgnoreCase(ext)
         || "jpeg".equalsIgnoreCase(ext)
         || "png".equalsIgnoreCase(ext);
   }
   return false;
 }
 /**
  * Apply the specified HTTP status code to the given response, if possible (that is, if not
  * executing within an include request).
  *
  * @param request current HTTP request
  * @param response current HTTP response
  * @param statusCode the status code to apply
  * @see #determineStatusCode
  * @see #setDefaultStatusCode
  * @see HttpServletResponse#setStatus
  */
 protected void applyStatusCodeIfPossible(
     HttpServletRequest request, HttpServletResponse response, int statusCode) {
   if (!WebUtils.isIncludeRequest(request)) {
     if (logger.isDebugEnabled()) {
       logger.debug("Applying HTTP status code " + statusCode);
     }
     response.setStatus(statusCode);
     request.setAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE, statusCode);
   }
 }
 /**
  * Shut down logback, properly releasing all file locks and resetting the web app root system
  * property.
  *
  * @param servletContext the current ServletContext
  * @see WebUtils#removeWebAppRootSystemProperty
  */
 public static void shutdownLogging(ServletContext servletContext) {
   servletContext.log("Shutting down logback");
   try {
     LogbackConfigurer.shutdownLogging();
   } finally {
     // Remove the web app root system property.
     if (exposeWebAppRoot(servletContext)) {
       WebUtils.removeWebAppRootSystemProperty(servletContext);
     }
   }
 }
 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
     throws Exception {
   UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
   Cart cart =
       (Cart)
           WebUtils.getOrCreateSessionAttribute(request.getSession(), "sessionCart", Cart.class);
   String page = request.getParameter("page");
   if (userSession != null) {
     if ("next".equals(page)) {
       userSession.getMyList().nextPage();
     } else if ("previous".equals(page)) {
       userSession.getMyList().previousPage();
     }
   }
   if ("nextCart".equals(page)) {
     cart.getCartItemList().nextPage();
   } else if ("previousCart".equals(page)) {
     cart.getCartItemList().previousPage();
   }
   return new ModelAndView(this.successView, "cart", cart);
 }
 @Override
 protected String getMediaTypeKey(NativeWebRequest webRequest) {
   HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
   if (request == null) {
     logger.warn("An HttpServletRequest is required to determine the media type key");
     return null;
   }
   String path = PATH_HELPER.getLookupPathForRequest(request);
   String filename = WebUtils.extractFullFilenameFromUrlPath(path);
   String extension = StringUtils.getFilenameExtension(filename);
   return (StringUtils.hasText(extension)) ? extension.toLowerCase(Locale.ENGLISH) : null;
 }
  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
      throws Exception {
    HttpSessionThreadLocal.set(request.getSession());
    String username = (String) WebUtils.getSessionAttribute(request, LoginController.USER_NAME);
    Long userId = (Long) WebUtils.getSessionAttribute(request, LoginController.USER_ID);
    logger.debug("Intercepting username: "******"Intercepting for object: " + handler.getClass().getName());
    if (username == null && userId == null) {
      if (checkForUserCookie(request, response)) {
        return true;
      }

      storeRequestInSession(request);
      logger.debug("username is null.  Not logged in.");
      ModelAndView modelAndView = new ModelAndView(view);
      throw new ModelAndViewDefiningException(modelAndView);
    } else {
      logger.debug("Logged in, returning true");
      return true;
    }
  }
 /**
  * Null safe means for retrieving the {@link Map} from the specified session keyed by {@link
  * #SESSION_ATTRIBUTE__PORTLET_FAILURE_CAUSE_MAP}.
  *
  * @param request HttpServletRequest
  * @return a never null {@link Map} in the session for storing portlet failure causes.
  */
 @SuppressWarnings("unchecked")
 protected Map<IPortletWindowId, Exception> getPortletErrorMap(HttpServletRequest request) {
   final HttpSession session = request.getSession();
   synchronized (WebUtils.getSessionMutex(session)) {
     Map<IPortletWindowId, Exception> portletFailureMap =
         (Map<IPortletWindowId, Exception>)
             session.getAttribute(SESSION_ATTRIBUTE__PORTLET_FAILURE_CAUSE_MAP);
     if (portletFailureMap == null) {
       portletFailureMap = new ConcurrentHashMap<IPortletWindowId, Exception>();
       session.setAttribute(SESSION_ATTRIBUTE__PORTLET_FAILURE_CAUSE_MAP, portletFailureMap);
     }
     return portletFailureMap;
   }
 }
Exemple #28
0
  public ActionForward search(
      ActionMapping mapping,
      ActionForm form, // 搜索
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    log.debug("search");

    Map filterMap = WebUtils.getParametersStartingWith(request, "search_");
    List vacationList = vacationService.searchByFilter(filterMap);

    request.setAttribute("vacationList", vacationList);
    request.setAttribute("show", "block");
    return mapping.findForward("goVacation");
  }
 @Override
 protected void doFilterInternal(
     HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
     throws ServletException, IOException {
   CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class.getName());
   if (csrf != null) {
     Cookie cookie = WebUtils.getCookie(request, "XSRF-TOKEN");
     String token = csrf.getToken();
     if (cookie == null || token != null && !token.equals(cookie.getValue())) {
       cookie = new Cookie("XSRF-TOKEN", token);
       cookie.setPath("/");
       response.addCookie(cookie);
     }
   }
   filterChain.doFilter(request, response);
 }
 private ServletRequest prepareServletRequest(
     Object target, NativeWebRequest request, MethodParameter parameter) {
   String modelPrefixName = parameter.getParameterAnnotation(FormModel.class).value();
   HttpServletRequest nativeRequest = (HttpServletRequest) request.getNativeRequest();
   MultipartRequest multipartRequest =
       WebUtils.getNativeRequest(nativeRequest, MultipartRequest.class);
   MockHttpServletRequest mockRequest = null;
   if (multipartRequest != null) {
     MockMultipartHttpServletRequest mockMultipartRequest = new MockMultipartHttpServletRequest();
     for (MultipartFile file : multipartRequest.getFileMap().values()) {
       mockMultipartRequest.addFile(
           new MultipartFileWrapper(getNewParameterName(file.getName(), modelPrefixName), file));
     }
     mockRequest = mockMultipartRequest;
   } else {
     mockRequest = new MockHttpServletRequest();
   }
   for (Entry<String, String> entry : getUriTemplateVariables(request).entrySet()) {
     String parameterName = entry.getKey();
     String value = entry.getValue();
     if (isFormModelAttribute(parameterName, modelPrefixName)) {
       mockRequest.setParameter(getNewParameterName(parameterName, modelPrefixName), value);
     }
   }
   for (Object parameterEntry : nativeRequest.getParameterMap().entrySet()) {
     Entry<String, String[]> entry = (Entry<String, String[]>) parameterEntry;
     String parameterName = entry.getKey();
     String[] value = entry.getValue();
     if (isFormModelAttribute(parameterName, modelPrefixName)) {
       mockRequest.setParameter(getNewParameterName(parameterName, modelPrefixName), value);
     }
   }
   return mockRequest;
 }