Hello I am trying to pass parameters from java to jsp file. But I am not getting it here is my code:
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView mav = new ModelAndView("SystemInfo", "System", "S");
request.setAttribute("JVMVendor", System.getProperty("java.vendor"));
response.setContentType("application/json;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
JSONObject jsonResult = new JSONObject();
jsonResult.put("JVMVendor", System.getProperty("java.vendor"));
jsonResult.put("JVMVersion", System.getProperty("java.version"));
jsonResult.put("JVMVendorURL", System.getProperty("java.vendor.url"));
jsonResult.put("OSName", System.getProperty("os.name"));
jsonResult.put("OSVersion", System.getProperty("os.version"));
jsonResult.put("OSArchitectire", System.getProperty("os.arch"));
response.getWriter().write(jsonResult.toString());
return mav; // return modelandview object
}
and in my jsp file I am using:
Ext.onReady(function(response) {
//Ext.MessageBox.alert('Hello', 'The DOM is ready!');
var showExist开发者_开发知识库ingScreen = function () {
Ext.Ajax.request({
url : 'system.htm',
method : 'POST',
scope : this,
success: function ( response ) {
var existingValues = Ext.util.JSON.decode(response.responseText);
}
});
};
return showExistingScreen();
});
Here's one way of doing what your title is asking for...
in java,
mav.addObject("ThingOne", "value of thing one.");
mav.addObject("ThingTwo", "value of thing two.");
in the jsp
<%@ taglib uri='http://java.sun.com/jstl/core' prefix='c'%>
...
<c:out value="${ThingOne}"/><br />
<c:out value="${ThingOne}"/>
...
should give you:
...
value of thing one.
value of thing two.
...
精彩评论