我无法从HttpServletRequest中读取参数:
我试过这种方法但没有工作。 public FormData readFormData(HttpServletRequest request,HttpServletResponse response,FilterChain chain)抛出IOException,ServletException,ParseException { FormData formData = null; 枚举paramNames = request.getParameterNames();
if(paramNames.hasMoreElements())
formData = new FormData();
while(paramNames.hasMoreElements())
{
String paramValue = null;
String paramName = (String)paramNames.nextElement();
//LOGGER.info("paramName :: " + paramName);
String[] paramValues = request.getParameterValues(paramName);
// Read single valued data
if (paramValues.length == 1) {
paramValue = paramValues[0];
/*if (paramValue.length() == 0)
LOGGER.info("<i>No Value</i>");
else
LOGGER.info("paramValue :: "+paramValue);*/
} else {
// Read multiple valued data
/*for(int i=0; i < paramValues.length; i++) {
LOGGER.info("<li>" + paramValues[i]+ "</li>");
}*/
}
String key = paramName;
if (key.equalsIgnoreCase("firstname"))
formData.setFirstName(paramValue);
if (key.equalsIgnoreCase("lastname"))
formData.setLastName(paramValue);
if (key.equalsIgnoreCase("username"))
formData.setUserName(paramValue);
if (key.equalsIgnoreCase("appusername"))
formData.setAppUserName(paramValue);
if (key.equalsIgnoreCase("time"))
{
Date time = dateFormatter.parse(paramValue);
formData.setTime(time);
}
if (key.equalsIgnoreCase("authhash"))
formData.setAuthHash(paramValue);
if (key.equalsIgnoreCase("mandate"))
formData.setMandate(paramValue);
}
return formData;
}
paramNames.hasMoreElements()
有假值!!
使用chrome检查器可以看到参数: