我是 Spring mvc3 portlet 和 dojo 的新手。我正在尝试在加载 jsp 时使用 JSON 数据填充选择下拉列表。我想使用 dojo 并在加载 jsp 时对控制器进行 ajax 调用并返回 JSON。任何提示都会有所帮助。
问问题
409 次
2 回答
0
@Controller
@RequestMapping("/yourController")
public class YourController
{
@RequestMapping(value="/combo/{id}", method=ReqestNethod.GET)
public String getDropDownData(@ParamValue("id") long id)
{
List<Combo> combos = commonDao.getCombos(id);
String json = JsonUtil.toJson(combos); // or whichever way you use
return json;
}
}
从 dojo 向这个 url 发送请求
<your-context-path>/yourController/combo/1
其中 1 是您的组合 ID。
我还没有检查这里的语法.. 盲写了。您可能会遇到编译错误。
于 2012-05-28T08:56:37.277 回答
0
我得到以下格式的数据 如何填充 dojoType="xwt.widget.form.FilteringSelect" {"ValuesDTO": {"items": [{},{"default": {"size": 5},"int “:10”,“字符串”:“产品1”,“字符串”:“产品1”,“字符串”:“产品3”,“字符串”:“产品4”,“字符串”:“产品5”}]}}
我在 bean 中发送 dat--->DTO--->List
于 2012-06-01T20:13:53.410 回答