小编Nan*_*ale的帖子

如何将Hashmap存储到android,以便在使用共享首选项重新启动应用程序时重用它?

我想将hashmap存储到我的android应用程序中,当重新启动时,它会显示最后保存的hashmap值.

HashMap<Integer,String> HtKpi=new HashMap<Integer,String>(); 
Run Code Online (Sandbox Code Playgroud)

是我的hashmap,44个值动态存储在其中.这工作正常!现在,我想将其存储以备将来使用(应用程序重启或重用).

java android hashmap sharedpreferences

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

在Spring中指定包含值的列表的最简单方法是什么?

假设我有一个很大的值列表aa bb cc dd ee ff gg等,我需要在春天作为构造函数传递

如果我需要配置为字符串数组,那么在spring中很容易,因为我们可以将值指定为逗号分隔为aa,bb,cc等,

如果我需要配置为列表,我需要像下面这样做

<bean name="myBean" class="MyClass">
    <constructor-arg>
        <list>
            <value>aa</value>
            <value>bb</value>
            <value>cc</value>
            <value>dd</value>
        </list>
    </constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)

当数值增加时,它占据了巨大的线条,看起来很丑陋.

有人可以帮助我如何将大值作为字符串中的列表作为构造函数传递?

java spring

12
推荐指数
3
解决办法
1万
查看次数

为什么可以在c中使用未定义的结构

#include <stdio.h>

int main()
{
  printf("%d", sizeof(struct token *));
}
Run Code Online (Sandbox Code Playgroud)

上面的代码可以在Linux下使用gcc编译和链接.你们中的任何人都可以向我解释场景背后的事情吗?我知道重点是内存的修复大小,所以struct token与sizeof无关,但是甚至打开gcc中的警告选项,根本没有关于"none exists"结构的警告.这个问题的上下文是我正在阅读其他人的一些源代码,我正在非常努力地找到"struct token"的定义,但当然失败了.

c

11
推荐指数
2
解决办法
868
查看次数

从excel单元格中读取日期值作为String

我正在使用apache poi库来读取excel文件.我在读密码单元时卡住了.如果用户在密码单元格中提供日期作为密码,即16/05/2012.我将此值读为"41045",而值应为"16/05/2012".这是我的代码:

cell = row.getCell(); // date in the cell password '16/05/2012'
switch (cell.getCellType()) {

case HSSFCell.CELL_TYPE_STRING:
    cellValue = cell.getRichStringCellValue().getString();
    break;
case HSSFCell.CELL_TYPE_NUMERIC:
    if(cellCount == TEMPLATE_PASSWORD) {// if cell is password
        cell.setCellType(Cell.CELL_TYPE_STRING);
        cellValue = cell.getRichStringCellValue().getString(); // value read is 41045 and not "16/05/2012"
    }
    break;
default:
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮忙吗?

谢谢.

java apache-poi

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

Eclipse不显示src文件

我的eclipse中有三个不同的项目,昨天的src文件在其中一个项目中变得不可见.两天前它还可以,我不知道这是怎么发生的.我无法在项目资源管理器或包浏览器中看到src文件.

Project Explorer:

Project Explorer

但是,如果我查看导航器,我可以看到目录中的所有文件.

导航器:

航海家

我在前两个项目中使用Eclipse Indigo SR2和IBM Rational ClearCase.另一个是我当地的测试项目.

有谁知道如何将src文件返回到项目资源管理器中?

谢谢.

java eclipse invisible project

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

Spring Security并发控制

我使用了spring security 3.0.7,我在我的项目中实现了并发控制.但它没有用.我用过

<security:session-management>
            <security:concurrency-control error-if-maximum-exceeded="true" max-sessions="1"/>
</security:session-management>
Run Code Online (Sandbox Code Playgroud)

即使我尝试过弹簧安全参考的解决方案,但它没有成功.这是我的配置文件内容:

  <session-management session-authentication-strategy-ref="sas"/>
</http>

<beans:bean id="concurrencyFilter"
   class="org.springframework.security.web.session.ConcurrentSessionFilter">
  <beans:property name="sessionRegistry" ref="sessionRegistry" />
  <beans:property name="expiredUrl" value="/session-expired.htm" />
</beans:bean>

<beans:bean id="myAuthFilter" class=
   "org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
  <beans:property name="sessionAuthenticationStrategy" ref="sas" />
  <beans:property name="authenticationManager" ref="authenticationManager" />
</beans:bean>

<beans:bean id="sas" class=
 "org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
  <beans:constructor-arg name="sessionRegistry" ref="sessionRegistry" />
  <beans:property name="maximumSessions" value="1" />
</beans:bean>

<beans:bean id="sessionRegistry"
    class="org.springframework.security.core.session.SessionRegistryImpl" />
Run Code Online (Sandbox Code Playgroud)

我得到以下异常:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Filter beans '<myAuthFilter>' and '<org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0>' have the same 'order' value. When using custom filters, please make sure the positions do …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security

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

Spring Security中的最大并发用户数

我在我的项目中使用Spring Security 3.0,并且限制用户最多只有一个会话.配置如下:

<security:session-management>
            <security:concurrency-control error-if-maximum-exceeded="true" max-sessions="1"/>
</security:session-management>
Run Code Online (Sandbox Code Playgroud)

我想在达到最大会话时打印自定义消息(不是由spring提供的默认消息).请帮忙.

提前致谢!!

java spring spring-security

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

内部类访问外部类方法,方法名称相同

我有一个类和一个子类

01 public class A{
02   void test(){};
03   public class B{
04     void test(){
05       test();
06     }
07   }
08 }
Run Code Online (Sandbox Code Playgroud)

好吧,在05行id喜欢访问类A的方法测试.但我进入循环因为我不知道如何指定使用类A的方法.

有任何想法吗?

java inner-classes

8
推荐指数
2
解决办法
8830
查看次数

什么<T>表示<T> void说()

<T>以下代码段中的含义是什么?

class Test {    
     <T> void say() {

     }    
}
Run Code Online (Sandbox Code Playgroud)

java generics

8
推荐指数
2
解决办法
7224
查看次数

运行时期间私有,公共,包关键字之间是否有任何区别?

我知道Java有这些serval关键字来识别开发过程中的变量范围,但是我想知道它在生产环境中是否有所不同,或者只是为了编码器的兴趣?谢谢.

java scope

7
推荐指数
2
解决办法
248
查看次数