3 回答

TA貢獻1804條經驗 獲得超7個贊
Form formPreview = new Form();
public Leaf(string name) : base(name) { }
public override void Add(Component c)
{
Console.WriteLine("Cannot add to a leaf");
}
public override void Remove(Component c)
{
Console.WriteLine("Cannot remove to a leaf");
}
public override void Display(int depth)
{
Console.WriteLine(new string('-',depth)+name);
}
}

TA貢獻1828條經驗 獲得超13個贊
這個很簡單可以使用spring mvc自帶的jackson
1、web工程lib中加入jackson所需jar包:jackson-core-asl-1.9.9.jar、jackson-mapper-asl-1.9.9.jar
2、在applicationContext.xml中加入jackson的配置
1 2 3 4 | <!-- json轉換器 --> <bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes" value="application/json" /> </bean> |
3、在你的action中直接使用注解的方式"@ResponseBody"自動將返回值轉化成json格式
1 2 3 4 5 6 7 8 9 | @Controller @RequestMapping("task") public class TaskControl { @RequestMapping("getUserById") @ResponseBody public List getUserById(Integer id) { return this.taskService.getUserById(id); } } |
4、jsp頁面的js寫法跟普通ajax格式一樣
1 2 3 4 5 | functon getUserById(id){ $.getJSON("task/getUserById",{id:id},function(data){
}); } |
- 3 回答
- 0 關注
- 1467 瀏覽
添加回答
舉報