尝试连接 LDAP 时出现套接字异常。这是我的示例代码。我在 java 8 中看到了这个问题。我从未在早期的 java 版本中观察到这个问题。
public static DirContext getDirectoryContext() throws NamingException {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
Common.getProperty("ldap.context.factory"));
env.put(Context.PROVIDER_URL,
Common.getProperty("ldap.provider.url"));
env.put(Context.SECURITY_AUTHENTICATION,
Common.getProperty("ldap.security.authentication"));
env.put(Context.SECURITY_PRINCIPAL,
Common.getProperty("ldap.security.principal"));
env.put(Context.SECURITY_CREDENTIALS,
Common.getProperty("ldap.security.credential"));
context = new InitialDirContext(env);
log.debug("NamingContext Initialized");
return context;
}
context = getDirectoryContext();
Run Code Online (Sandbox Code Playgroud)
我对所有 LDAP 调用使用相同的上下文。
private NamingEnumeration getResultsFromLdap(String searchFilter) {
NamingEnumeration results = null;
try {
// Getting the list from LDAP matching the given filter
SearchControls sControls = new SearchControls();
sControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String baseContext = Common.getProperty("ldap.base.context");
results = context.search(baseContext, searchFilter, …Run Code Online (Sandbox Code Playgroud) 在我的JSF2应用程序中,我在Primefaces(5.1)自动完成时遇到了NPE
org.primefaces.component.autocomplete.AutoCompleteRenderer
.encodeSuggestionsAsList(AutoCompleteRenderer.java:492)
我通过替换maven依赖来解决我的问题
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
通过
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这让我很困惑.
在搜索项目主页时,我发现了这些maven存储库:
http://mvnrepository.com/artifact/com.sun.faces/jsf-impl/2.2.4
http://mvnrepository.com/artifact/org.glassfish/javax.faces/2.2.4
他们都声称相同的描述并引用与主页相同的URL:
描述:Oracle对JSF 2.2规范的实现(2.2.4)
主页:http://java.sun.com/javaee/javaserverfaces/
有人可以解释这个区别吗?不应该完全一样吗?
提示:我了解太阳和甲骨文的历史.;)
有没有办法推迟一个keyup ajax请求,直到啊:inputText值已达到定义的长度?
我想达到以下目标:textInput字段必须填充组合的日期和时间值.预期的格式是:ddMMHHmm
一旦值达到8个字符的长度,就必须将新的事件对象添加到数据列表中,并且应该立即显示以进行确认.要确认添加新事件,用户只需在此textInput字段中按Enter键即可.
我不知道是否有不同的功能,而不是使用ajax keyUp事件验证输入没有任何进一步的用户交互?
在这里,您可以看到我的想法的一个非常简短的例子:
@Named
@SessionScoped
public class EventController {
private Date selectedDate; // +getter/+setter
private MyEvent event;
private List<MyEvent> events; // ArrayList<MyEvent>(), +getter
@PostConstruct
private void init() {
// load current events from DAO
}
public void validateInput() {
event = new MyEvent(selectedDate);
events.add(event);
}
public void confirmEvent() {
eventDAO.addEvent(event);
}
Run Code Online (Sandbox Code Playgroud)
并且观点:
<h:inputText
value="#{eventController.selectedDate}"
converter="#{comfortableDateTimeInputConverter}"
id="inputDateTime">
<f:ajax
<!-- pseudo code on !!! -->
executeCondition="<lengthOfInputField equals 8>"
<!-- pseudo code off !!! -->
execute="inputDateTime"
render="eventData"
event="keyup" …Run Code Online (Sandbox Code Playgroud) 为什么当我运行它时它给出零而不是字符a:
public class Main {
public static void main(String[] args) {
int num = 79;
char a = 'a';
System.out.println((char)num);
}
}
Run Code Online (Sandbox Code Playgroud)