小编arv*_*unk的帖子

找出另一个arraylist中没有的arraylist的元素

我必须找到一种最好的方法来找出第二个arraylist中没有出现的元素.假设

Arraylist a,b, 

Arraylist a={1,2,3,4,5};
Arraylist b={2,3,4};
Run Code Online (Sandbox Code Playgroud)

所以基本上我要的是找出的元素一个是不存在的ArrayList b.

那么这样做的最佳解决方案是什么?

java arrays collections list arraylist

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

如何在eclipse或jar-file-explorer中查看jar文件的内容

我正在开发一个项目,我需要知道我的web项目中包含的jar文件的内容.我正在使用Eclipse juno.但是,Netbeans提供了这些功能来查看jar文件的内容.请建议我如何在eclipse中实现这一点.

java eclipse eclipse-plugin jar

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

String.valueOf(String Object)的null和"null"有什么区别

在我的项目中,如果其他条件检查空变量,我必须使用

String stringValue = null;
String valueOf = String.valueOf(stringValue);
Run Code Online (Sandbox Code Playgroud)

但是当我检查条件时

  if (valueOf == null) {
        System.out.println("in if");
    } else {
        System.out.println("in else");
    }
Run Code Online (Sandbox Code Playgroud)

然后输出是"在其他地方",为什么会发生这种情况?

java string null if-statement object

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

使用hibernate标准进行左连接

我有两个实体:IssueIssue_Tracker.我正在使用Hibernate 3.6.

SELECT `issues`.`issue_id`,
       `issues`.`issue_raised_date`,
       `issues`.`issue_description`,
       `issue_tracker`.`tracker_status`
FROM `issues`
   LEFT JOIN  `issue_tracker` ON `issues`.`issue_id` = `issue_tracker`.`issue_id`
WHERE `issues`.`status`="Escalate To"
Run Code Online (Sandbox Code Playgroud)

如何使用Hibernate Criteria实现这一点,最重要的是,我必须将它用于分页.

和My Dao如下显示jqgrid中的问题列表

public List showHelpDeskIssues(DetachedCriteria dc,int from,int size){

Session session = HibernateUtil.getSessionFactory().getCurrentSession();
 try
  {

    Criteria criteria = dc.getExecutableCriteria(session);
    criteria.setFirstResult(from);
    criteria.setMaxResults(size);
    criteria.add(Restrictions.eq("status","Escalate To"));

    return criteria.list();
  }
  catch (HibernateException e)
  {
    e.printStackTrace();
    throw e;
  } }
Run Code Online (Sandbox Code Playgroud)

有关简要说明请参考此问题如何使用struts2在jqgrid中显示两个表数据 - jqgrid插件和hibernate 任何帮助都会很棒.

java mysql hibernate hibernate-criteria

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

如何在primefaces中禁用数据表的行选择

我正在使用Primefaces 4.0,我有一个具有多个选择功能的数据表.我愿意实现的是仅通过复选框按钮选择行,禁用单击行的功能.在目前的情况下我的复选框被选中,即使我点击任何一行,我想禁用行选择.

<p:dataTable id="tradingTable" scrollable="true"
                resizableColumns="true" draggableColumns="true"  scrollWidth="1265"
                scrollHeight="650" var="pgers"
                selection="#{pager.selectedPageArray}"
                value="#{pager.pageDataModel}"
                sortMode="multiple"
                editable="true" editMode="cell" 
                rowSelectMode="add"     

                >  
                <p:column width="30" selectionMode="multiple"   >
                </p:column> 
Run Code Online (Sandbox Code Playgroud)

我从这个论坛得到了一些解决方案,但无法解决.请建议我需要做什么.

jquery jsf datatables primefaces

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

面对Primefaces 4和5中的关键性能问题

我正在开发一个处理繁重数据集的项目.我正在使用Primefaces 4&5,spring和hibernate.我必须显示一个非常庞大的数据集,如min 3000行,100列,各种功能,如排序,过滤,行扩展等.我的问题是,我的应用程序需要8到10分钟来显示整个页面以及其他功能(排序,过滤)也需要很多时间.我的客户根本不开心.但是,我可以使用分页,但我的客户端不再需要分页.所以我决定使用livescroll,但遗憾的是我没有使用lazyload或没有lazyload实现livescroll,因为PF中有关于livescroll的错误.我也早些时候在这里发布了这个问题但没有找到解决方案.

这个性能问题非常关键,对我来说显示了阻碍.要显示包含100列的3000行,加载的页面大小约为10MB.我已经计算了JSF各种生命周期所消耗的时间,使用Phase-listener我发现它的浏览器正在花时间解析jsf呈现的响应.为了完成所有阶段,我的申请仅用了25秒.最小化我想提高我的项目的性能.请分享任何有助于克服此问题的想法,建议和任何内容

注意:getter和setter中没有数据库操作,也没有复杂的业务逻辑.

更新: 这是我没有lazyload的数据表:

<p:dataTable 
                style="width:100%"
                id="cdTable"
                selection="#{controller.selectedArray}"
                resizableColumns="true" 
                draggableColumns="true" 
                var="cd"
                value="#{controller.cdDataModel}"
                editable="true" 
                editMode="cell"
                selectionMode="multiple"
                rowSelectMode="add"
                scrollable="true"
                scrollHeight="650"
                rowKey="#{cd.id}"
                rowIndexVar="rowIndex"
                styleClass="screenScrollStyle"
                liveScroll="true"
                scrollRows="50"
                filterEvent="enter"
                widgetVar="dt4"
                >
Run Code Online (Sandbox Code Playgroud)

这里除了过滤外,一切正常.一旦我过滤,则显示第一页但无法对数据表进行排序或实时滚动.请注意,我在Primefaces5中进行了测试.

第二个Approch

使用具有相同数据表的lazyload 1)当我添加rows ="100"时会发生livescroll但行编辑,行扩展但过滤和排序的问题仍然存在.2)当我删除行时, livescroll适用于行编辑,行扩展等,但过滤和排序不起作用.

我的LazyLoadModel如下

public class MyDataModel extends LazyDataModel<YData> 
         {

    @Override
    public List<YData> load(int first, int pageSize,
            List<SortMeta> multiSortMeta, Map<String, Object> filters) {
        System.out.println("multisort wala load"); …
Run Code Online (Sandbox Code Playgroud)

primefaces jsf-2 primefaces-extensions

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

抛出异常时如何回滚Spring事务

我使用的是Spring 3.0.5和hibernate 3.6.在我的项目中有一种情况,我必须回滚抛出的任何异常的事务或发生错误.这个示例代码,Everything工作正常,但是当我抛出异常时事务没有被回滚但是如果抛出任何异常,例如mysql.IntegrityConstraintException, 那么事务会被回滚,为什么在我的情况下不会发生这种情况?

applicationContext.xml中

    <bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:database.properties"/>
    </bean>
      <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="${jdbc.driverClassName}" />
            <property name="url" value="${jdbc.url}" />
            <property name="username" value="${jdbc.username}" />
            <property name="password" value="${jdbc.password}" />

        </bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
 <property name="dataSource" ref="myDataSource" />
    <property name="packagesToScan" value="com.alw.imps"/>
    <property name="configLocation">    
        <value>
            classpath:hibernate.cfg.xml
        </value>
     </property>
    </bean>

    <bean id="stateDao" class="com.alw.imps.dao.StateDaoImpl">
     <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>


        <bean id="stateService" class="com.alw.imps.services.StateService">
       <property name="stateDao" ref="stateDao"></property>
       <property name="cityDao" ref="cityDao"></property>
       <property name="customerDao" ref="customerDao"></property>
       </bean>  

        <bean id="customerDao" class="com.alw.imps.dao.CustomerDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"></property>
       </bean> 

            <bean id="cityDao" …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate exception spring-transactions

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

如何使用Spring Ldap身份验证

在我当前的项目中,我必须实现LDAP身份验证.我正在使用JSF 2.2,primefaces和Spring 4.0以及spring-ldap-core 1.3.2和spring-security-ldap-3.2.0.以下是迄今为止我所做的工作:

弹簧Ldap.xml

<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
 <property name="url" value="ldap://mumcXXXXXXX" />
 <property name="base" value="dc=ad,dc=XXX,dc=com"/>
 <property name="userDn" value="XXXX@ad.XXX.com" />
 <property name="password" value="XXXX" />
 </bean>

 <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
    <constructor-arg ref="contextSource" />
</bean>

<bean id="ldapContact"
    class="com.csap.research.LDAPContactDAO">
    <property name="ldapTemplate" ref="ldapTemplate" />
</bean>
Run Code Online (Sandbox Code Playgroud)

我的LdapContactDao

public boolean login(String username, String password) {
        AndFilter filter = new AndFilter();
        ldapTemplate.setIgnorePartialResultException(true); 
        filter.and(new EqualsFilter("userPrincipalName", username+"@ad.cXXX.com"));
        return ldapTemplate.authenticate("", filter.toString(), password);
}
Run Code Online (Sandbox Code Playgroud)

此处,用户名和密码来自登录屏幕作为输入.我的问题是它非常硬编码.我不想在Spring-Ldap.xml中硬编码用户名密码,所以有人建议在这里使用Spring-security-Ldap Spring LdapAuthentication和从本地数据库加载角色但我无法理解它.

我的问题是如何实现Ldap与spring和corse的动态集成,我将其用作前端控制器.任何帮助都会很棒.

spring ldap spring-ldap

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

使用struts2从jsp页面的隐藏字段获取arraylist到action类

我有一个arraylist,我已经设置为jsp的hiddenField.Now我必须在我的动作类中访问此列表.下面是代码片段如下

我的行动班

private ArrayList<TXT_File_Action> statusResult_list=new ArrayList<TXT_File_Action>();
    private ArrayList<TXT_Beans> regenerateTXTList=new ArrayList<TXT_Beans>();
    private ArrayList<TXT_Beans> pagingList=new ArrayList<TXT_Beans>();
    private ArrayList<TXT_Beans> serverList=new ArrayList<TXT_Beans>();



public String getGenerateList()
    {

          for(int j=0;j<customers_accountList.size();j++)
               {

               dataList=txt_managerInstance.regenerateListData(id_no);  
               regenerateTXTList.add(dataList.get(0));
           }

               pagingList=getRegenerateTXTList();
               setRegenerateTXTList(getRegenerateTXTList());
               setPagingList(getPagingList());

        return SUCCESS;
      }

  getters..n setters
Run Code Online (Sandbox Code Playgroud)

我的JSP代码是

 <s:iterator value="pagingList">
<tr>
     <td align="center"><s:property value="customerId" /></td>  
     <td align="center"><s:property value="cspId" /></td>    
     <td align="center"><s:property value="branchCode" /></td>
     <td align="center" id="bcID"><s:property value="bcCode"/></td>
 </tr>

</s:iterator>
Run Code Online (Sandbox Code Playgroud)

在下面我在jsp隐藏字段中设置列表,如下所示:

   <input type="hidden" name="serverList" id="serverList"  value="<s:property value="pagingList"/>"/>
Run Code Online (Sandbox Code Playgroud)

现在,当我点击某个活动时,我想在我的动作类中使用此列表.每当我尝试在我的操作中打印此列表serverList的大小时,我得到以下错误:

java.lang.ArrayIndexOutOfBoundsException: -1
    java.util.ArrayList.get(Unknown Source)
    com.alw.action.TXT_File_Action.setPaginationList(TXT_File_Action.java:424)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    java.lang.reflect.Method.invoke(Unknown …
Run Code Online (Sandbox Code Playgroud)

java jsp struts2 list hidden-field

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

我可以在课堂上有两个以上的块

我正在开展一个项目,我需要执行两个不同的操作.我的主控制器方法中有一个finally块.

我的问题是,我最终可以有两个以上,例如:

class test
{
    X()
    {
        try
        {
            //some operations
        }
        finally
        {
            // some essential operation
        }

    }

    //another method
    Y()
    {
        try
        {
            //some operations
        }
        finally
        {
            // some another essential operation
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

那么,有可能吗?

java exception-handling exception try-catch try-catch-finally

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