这是我的js文件,它将查询字符串参数传递给控制器。
function viewSelectedTravelerDetails(taNumber,country,city)
{
// clearMessageBar();
if(taNumber != "")
{
var url = "travelerdetailview.htm?requestAction=viewTravelerDetails&taNumber="+taNumber+'&country='+country+'&city='+city;
//var url = "travelerdetailview.htm?requestAction=viewTravelerDetails&taNumber="+taNumber;
var windowName = "traveler_detail";
var retValue = openNewWindow(url,windowName,"width=1024px,height=768px,center=1, status=0, titlebar=0, margin=0 auto,scrollbars=yes");
}
}
这是控制器方法,它处理上述请求的URL并在其他记录的情况下返回视图。
private ModelAndView handleTravelerDetailView(
HttpServletRequest request
, HttpServletResponse response
, Object command
, BindException errors
) throws Exception {
String taNumber = request.getParameter("taNumber");
String country = request.getParameter("country");
String city = request.getParameter("city");
logIt.info( "Traveler city(ISO_8859_1):" + city );
byte[] bytes = city.getBytes( StandardCharsets.ISO_8859_1 );
city = new String( bytes, StandardCharsets.UTF_8 );
logIt.info( "Traveler city(UTF-8):" + city );
TravelerCO travelerViewData = migrateDataService.retrieveTravelerFullData( taNumber, country, city );
logIt.info( "Traveler city(retrieveTravelerFullData):" + travelerViewData.getTravelerCity() );
return new ModelAndView( getSuccessView(), getCommandName(), travelerViewData );
}
如果url包含非ascii字符(如
),则无法处理请求travelerdetailview.htm requestAction = viewTravelerDetails&安培; taNumber = TA17 / 1246&安培;国家=安培;城市= 无
为什么我会收到400错误请求错误?请注意网址中的UTF-8字符。