我有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
.怎么了?
我在 Spring 有一个小项目。它位于(例如)中C:/users/projects/blog
。我怎样才能得到这条路?
我试图使用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) 我想从名为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 ×4
spring ×2
biginteger ×1
collections ×1
cookies ×1
directory ×1
file ×1
hibernate ×1
long-integer ×1
properties ×1
session ×1
string ×1