小编Ere*_*rez的帖子

存在可选的long参数但不能转换为空值

嗨我正在网上开发所以我有一个ajax函数调用一个控制器函数调用DAO函数(在DB上进行更改).我在控制器功能中得到了上面的例外..

控制器功能:

@RequestMapping(value="/changeIsPublic", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public  @ResponseBody boolean changeIsPublic(HttpServletRequest request, Locale locale, Model model, long transactionId, boolean isPublic) {
    boolean result = false; 
    try {
            boxDao.changeIsPublicStatus(transactionId, isPublic);
            result = true;

        } catch (Exception e) {
            logger.debug("Failed to publish transaction. transaction ID: " + transactionId + e.getMessage());
        }
        return result;
}
Run Code Online (Sandbox Code Playgroud)

DAO功能:

public Box changeIsPublicStatus(long id, boolean isPublic) {
    Criteria criteria = getCurrentSession().createCriteria(Box.class);
    criteria.add(Restrictions.eq("id", id));
    Box transaction = (Box) criteria.uniqueResult();
    transaction.setIsPublic(isPublic);
    return transaction;
}
Run Code Online (Sandbox Code Playgroud)

例外:

    SEVERE: Servlet.service() for servlet …
Run Code Online (Sandbox Code Playgroud)

java dao controller exception java-ee

15
推荐指数
5
解决办法
3万
查看次数

标签 统计

controller ×1

dao ×1

exception ×1

java ×1

java-ee ×1