小编Ton*_*ony的帖子

java.math.BigInteger无法强制转换为java.lang.Long

我有List<Long> dynamics.我希望得到最大的结果Collections.这是我的代码:

List<Long> dynamics=spyPathService.getDynamics();
        Long max=((Long)Collections.max(dynamics)).longValue(); 
Run Code Online (Sandbox Code Playgroud)

这是我的getDynamics:

public List<Long> getDynamics() {

        Session session = null;

        session = this.sessionFactory.getCurrentSession();
        Query query = session
                .createSQLQuery("SELECT COUNT(*) FROM SpyPath WHERE DATE(time)>=DATE_SUB(CURDATE(),INTERVAL 6 DAY) GROUP BY DATE(time) ORDER BY time;");

        List<Long> result = query.list();
        return result;

    }
Run Code Online (Sandbox Code Playgroud)

现在我来了java.math.BigInteger cannot be cast to java.lang.Long.怎么了?

java collections hibernate biginteger long-integer

22
推荐指数
3
解决办法
10万
查看次数

如何在Spring中获取当前目录?

我在 Spring 有一个小项目。它位于(例如)中C:/users/projects/blog。我怎样才能得到这条路?

java string directory spring

6
推荐指数
2
解决办法
2万
查看次数

Spring MVC的Cookie问题

我试图使用cookie值@Cookie.但是如果cookie值为null,我会得到400错误.怎么了?这是我的控制器:

    public String listContacts(Map<String, Object> map,
            HttpServletResponse response, @CookieValue("flag") String flag) {



        response.addCookie(new Cookie("flag", "In use"));
...
Run Code Online (Sandbox Code Playgroud)

java cookies session spring

1
推荐指数
1
解决办法
2964
查看次数

如何从属性文件读取?

我想从名为jdbc.properties的属性文件中读取一行。它位于中src\main\webapp\WEB-INF\db\jdbc.properties。我应该使用什么路径?这是我的方法:

Properties prop = new Properties();

        try {
            // load a properties file
            prop.load(new FileInputStream("jdbc.properties"));

            System.out.println(prop.getProperty("password"));

        } catch (IOException ex) {
            ex.printStackTrace();
        }
Run Code Online (Sandbox Code Playgroud)

java properties file

0
推荐指数
1
解决办法
3803
查看次数