我试图使用hibernate ORM从数据库中检索数据并使用struts获取输出为json结果2.一切都可以从DB中检索数据。但是对于json结果我只得到 {} 。我想我的编码做错了。但需要一些帮助才能搞清楚。感谢。
这是我的Action类:
@ParentPackage("json-default")
public class SocialIconsAction extends ActionSupport {
private List<TiendayaCurrencies> _currency;
public List<TiendayaCurrencies> getCurrency() {
return _currency;
}
public void setCurrency(List<TiendayaCurrencies> _currency) {
this._currency = _currency;
}
@Action(value = "currencies", results = {
@Result(name = "success", type = "json", params = {"includeProperties",
"_currency\\[\\d+\\]\\..*"})})
@Override
public String execute() {
_currency = loadCurrencies();
/*Nothing wrong with the DB results.Just to test everything works fine.*/
//for (TiendayaCurrencies _currency1 : _currency) {
// System.out.println("Title - "+_currency1.getTitle());
// }
return SUCCESS;
}
private List<TiendayaCurrencies> loadCurrencies() {
Session session = com.tiendaya.connection.HibernateUtil.
getSessionFactory().openSession();
List<TiendayaCurrencies> cList = session.
createCriteria(TiendayaCurrencies.class).list();
return cList;
}
}
Pojo课程:
public class TiendayaCurrencies{
private Integer id;
private String title;
private String code;
private String symbolLeft;
private String symbolRight;
private char decimalPlace;
...
includeProperties 有什么问题吗?(只有我能想到的地方......)任何人都可以提出建议......我已经尝试了一切......