import org.apache.commons.lang3.StringEscapeUtils; //導入方法依賴的package包/類
/**
* Handle request.
*
* @param request the request
* @param response the response
* @return the model and view
* @throws Exception the exception
*/
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(
final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
final Map list = getBeans(this.applicationContext);
LOGGER.debug("Found [{}] beans to report", list.size());
final JsonSerializer serializer = new BeanObjectJsonSerializer();
final StringBuilder builder = new StringBuilder();
builder.append('[');
final Set> entries = list.entrySet();
final Iterator> it = entries.iterator();
while (it.hasNext()) {
final Map.Entry entry = it.next();
final Object obj = entry.getValue();
final StringWriter writer = new StringWriter();
writer.append('{');
writer.append('\"' + entry.getKey() + "\":");
serializer.toJson(writer, obj);
writer.append('}');
builder.append(writer);
if (it.hasNext()) {
builder.append(',');
}
}
builder.append(']');
final ModelAndView mv = new ModelAndView(VIEW_CONFIG);
final String jsonData = StringEscapeUtils.escapeJson(builder.toString());
mv.addObject("jsonData", jsonData);
mv.addObject("properties", casProperties.entrySet());
return mv;
}