小编Mah*_*leh的帖子

java.net.ConnectException:连接到 ldap 时连接超时

我正在尝试使用spring ldap 1.3.1.RELEASE连接到Windows Server 2008上的ldap 活动目录 ,并且 ldap 配置如下:

  • LDAP 网址为:ldap://dc.fabrikam.com
  • 用户名:管理员
  • 密码:123456

- spring ldap配置如下:

    <bean id="contextSource" 
    class="org.springframework.ldap.core.support.LdapContextSource">
    <property name="url" value="ldap://dc.fabrikam.com" />
    <property name="base" value="dc=fabrikam,dc=com" />     
    <property name="userDn" value="CN=administrator,CN=Users,DC=fabrikam,DC=com" />     
    <property name="password" value="123456" />


    <property name="baseEnvironmentProperties">
    <map>
        <entry key="java.naming.referral">
            <value>follow</value>
        </entry>
    </map>
    </property>

</bean>

<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
    <constructor-arg ref="contextSource" />
</bean>
Run Code Online (Sandbox Code Playgroud)
  • LDAPContactDAO:

    @Service
    public class LDAPContactDAO implements ContactDAO {
    
    @Autowired
    private LdapTemplate ldapTemplate;
    
    public List getAllContactNames() {
        return ldapTemplate.search("", "(objectclass=person)", …
    Run Code Online (Sandbox Code Playgroud)

spring ldap active-directory spring-ldap

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

ldap搜索非常慢

我正在使用JNDI连接到LDAP活动目录,我想搜索名称中包含搜索字符串的用户,所以我的搜索方法如下:

public static List<LDAPUser> searchContactsByName(
        ExtendedDirContext extendedDirContext, String name) {

    try {

        LdapContext ldapContext = extendedDirContext.getLdapContext();
        String searchBaseStr = extendedDirContext.getSearchBase();

        String sortKey = LDAPAttributes.NAME;
        ldapContext.setRequestControls(new Control[] { new SortControl(
                sortKey, Control.CRITICAL) });

        SearchControls searchCtls = new SearchControls();
        searchCtls.setTimeLimit(1000 * 10);

        String returnedAtts[] = { LDAPAttributes.USER_NAME,
                LDAPAttributes.NAME };
        searchCtls.setReturningAttributes(returnedAtts);

        searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);

        String searchFilter = "(&(ObjectCategory=person)(cn=*" + name
                + "*))";

        NamingEnumeration<SearchResult> results = ldapContext.search(
                searchBaseStr, searchFilter, searchCtls);

        List<LDAPUser> users = new ArrayList<LDAPUser>(0);
        while (results.hasMoreElements()) {
            SearchResult sr = (SearchResult) results.next();
            Attributes attrs = …
Run Code Online (Sandbox Code Playgroud)

java jndi ldap active-directory

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

如何在selectOneButton中的按钮之间添加空格

我正在使用selectOneButton,我想在按钮之间添加空格,如果可能的话,更改选择背景颜色,请告知如何做到这一点,谢谢.

这是代码:

    <p:selectOneButton value="#{buttonBean.number}">  
        <f:selectItem itemLabel="Option 1" itemValue="1" />  
        <f:selectItem itemLabel="Option 2" itemValue="2" />  
        <f:selectItem itemLabel="Option 3" itemValue="3" />  
    </p:selectOneButton>
Run Code Online (Sandbox Code Playgroud)

css jsf primefaces

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

CDI @ViewScoped bean 功能不可用

我在 Spring Boot 1.4.4 中使用 JSF 2.2.14,我定义了一个自定义视图范围,如下所示:

public class FacesViewScope implements Scope {

    public static final String NAME = "view";

    @Override
    public Object get(String name, ObjectFactory<?> objectFactory) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        if (facesContext == null) {
            throw new IllegalStateException("FacesContext.getCurrentInstance() returned null");
        }

        Map<String, Object> viewMap = FacesContext.getCurrentInstance().getViewRoot().getViewMap();

        if (viewMap.containsKey(name)) {
            return viewMap.get(name);
        } else {
            Object object = objectFactory.getObject();
            viewMap.put(name, object);

            return object;
        }
    }

    @Override
    public Object remove(String name) {
        return FacesContext.getCurrentInstance().getViewRoot().getViewMap().remove(name);
    }

    @Override
    public String getConversationId() { …
Run Code Online (Sandbox Code Playgroud)

jsf spring jsf-2.2 spring-boot

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

阿拉伯语显示为????? 在速度模板中

问候我在发送电子邮件时使用速度模板,在模板中我有一些阿拉伯语文本

并且在发送电子邮件时,文本显示为?????????? 我不知道为什么:

在此处发送电子邮件之前,encoding设置为utf-8:

VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,templateName, "UTF-8",newModel);
Run Code Online (Sandbox Code Playgroud)

我试图在vm中添加charset,但没有运气:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Run Code Online (Sandbox Code Playgroud)

任何想法为何会出现这种问题?

spring velocity spring-mvc java-ee

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

从文本中删除除 &lt;br&gt; 之外的所有 HTML 标签?

大家好,我有一个java字符串,我想删除除新行标签之外的所有html标签<br>,</br>并将文本保留在标签内(如果有文本)。2-解析文本结果后相互连接,如: text1andtext2 ,文本之间没有空格分隔,我也想这样做。

这就是我正在做的:

String html = "<div dir=\"ltr\">hello my friend<span>ECHO</span><br>how are you ?<br><br><div class=\"gmail_quote\">On Mon, Feb 14, 2011 at 10:45 AM, My Friend <span dir=\"ltr\">&lt;<a href=\"mailto:notifications@mydomain.com\">notifications@mydomain.com</a>&gt;</span> wrote:<br> "
            + "<blockquote class=\"gmail_quote\" style=\"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;\"> ";
    String parsedText = html.replaceAll("\\<.*?\\>", "");
    System.out.println(parsedText);
Run Code Online (Sandbox Code Playgroud)

电流输出:

hello my friendECHOhow are you ?On Mon, Feb 14, 2011 at 10:45 AM, My Friend &lt;notifications@mydomain.com&gt; wrote:
Run Code Online (Sandbox Code Playgroud)

期望的输出:

hello my friend ECHO <br> …
Run Code Online (Sandbox Code Playgroud)

java regex

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

使用和/或在JasperReport表达式中

我想使用和/或在JasperReport表达式中我尝试了以下但它不起作用:

($P{pId} == $F{id1}) or
($P{pId} == $F{id2} and F{return}=true)
? "good" : "bad"
Run Code Online (Sandbox Code Playgroud)

但我得到以下例外:

Compilation exceptions: com.jaspersoft.ireport.designer.compiler.ErrorsCollector@1c9f37d  net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, calculator_report1_1318247835062_860381: 191: unexpected token: or @ line 191, column 144. 1 error      at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:88)     at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:188)     at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:215)     at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:131)     at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:509)     at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)     at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
Run Code Online (Sandbox Code Playgroud)

任何想法为什么我得到这个例外以及如何解决它.

java jasper-reports ireport

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

选择身份验证提供程序jdbc-user-service vs user-service-ref

我想实现spring security登录并记住我,我在使用jdbc-user-service或user-service-ref之间感到困惑, 因为我的身份验证提供者可以请任何人向我描述两者之间有什么区别,何时去一个或者另一个,因为我能看到的是两者都用于查找用户.

spring spring-security

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

如何在Eclipse中设置svn ignore属性

我想将SVN ignore属性添加到我的项目中以忽略目标文件夹和.classpath.

所以我通过团队→设置属性,但我不知道名称和值的配置如何.我该怎么做?

eclipse subclipse svn subversive svnignore

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

Mojarra 2.1.0 - FCS不能与tomcat 7一起使用

我使用JSF 2.1(Mojarra 2.1.0 - FCS)与tomcat 7如下:

<dependency>
 <groupId>com.sun.faces</groupId>
 <artifactId>jsf-api</artifactId>
 <version>2.1.0-b11</version>
 <scope>compile</scope>
 </dependency>

 <dependency>
 <groupId>com.sun.faces</groupId>
 <artifactId>jsf-impl</artifactId>
 <version>2.1.0-b11</version>
 <scope>compile</scope>
 </dependency>
Run Code Online (Sandbox Code Playgroud)

当我试图在tomcat 7上运行它时,我得到以下异常:

java.lang.InstantiationException: com.sun.faces.application.ServletContextSensitiveSingletonStore
    at java.lang.Class.newInstance0(Class.java:340)
    at java.lang.Class.newInstance(Class.java:308)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4268)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4771)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:785)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:763)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:558)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:674)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:599)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:538)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1390)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:355)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:312)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:292)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:998)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:772)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:990)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:424)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:648)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:576) …
Run Code Online (Sandbox Code Playgroud)

java-ee jsf-2 tomcat7

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