在验证我的用户之后,我想在会话中将引用添加到当前登录用户.
这里我是如何在setCurrentUser方法中做到的:
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
session.setAttribute("CURRENT_USER", currentUser);
Run Code Online (Sandbox Code Playgroud)
不幸的是,session引用始终为null!
或者,我尝试使用sessionMap
FacesContext facesContext = FacesContext.getCurrentInstance();
Map<String, Object> sessionMap = facesContext.getExternalContext().getSessionMap();
sessionMap.put("CURRENT_USER", currentUser);
Run Code Online (Sandbox Code Playgroud)
这个例外情况很糟糕:
java.lang.UnsupportedOperationException
at java.util.AbstractMap.put(AbstractMap.java:186)
(...)
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么 ?
我的控制器的完整代码
UserController.java
public class UserController implements Filter {
private FilterConfig fc;
private static final String CURRENT_USER = "CURRENT_USER";
public void init(FilterConfig filterConfig) throws ServletException {
fc = filterConfig;
log(">> Filter initialized");
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException …Run Code Online (Sandbox Code Playgroud) 可能重复:
从字符串中提取regexp结果并将其写入变量
这是我的命令:
grep -E'\*[[:space:]] + FIN [[:space:]] +([^]] +?)')myfile
它输出:
- FIN(成功)
而且我希望它只输出:
成功
我grep怎么知道呢?
我已经用谷歌搜索并搜索了文档。我被困在这个问题上。
你知道subversion 忽略的文件列表位于哪里吗?
我在低功耗运行模式下从RAM 运行了 c代码(因此中断没有处理).此模式由代码序列启用:
所以在勘误表中描述的WFE指令没有问题.这种结构的问题,可能是永远低功耗等待模式下 CPU锁定的原因:
while nbit(TIM1_SR1,CC3IF) asm("wfe");
Run Code Online (Sandbox Code Playgroud)
这是拆卸为:
000035 720252B602 BTJT TIM1_SR1, #1, 0xB6
00003A 728F WFE
Run Code Online (Sandbox Code Playgroud)
来自定时器的事件具有概率性质,并且此代码不保证在WFE指令执行后它将发生:
我使用手册PM0044,在第26页它内容漂亮的表:
有两种情况,代码执行在3个周期停止.所以我不确定在BTJT和WFE指令之间不会发生异步唤醒事件.
有没有办法确保严格的逻辑顺序(检查条件> wfe>唤醒事件)?
我有一个 html 文件,我想使用第一个 div 标签遍历该文件图像显示 我的代码的 html 文件结构
public static void ExtractChild(String content) {
String data = content;
ArrayList<String> childList = new ArrayList<String>();
try{
Document document = Jsoup.parse(data);
Element div = document.select("div").first();
Elements divChildren = div.children();
int size = divChildren.size();
if (size > 0) {
for (int i = 0; i < size; i++) {
data = divChildren.get(i).toString();
System.out.println(data);
ExtractChild(data);
}
} else {
childList.add(data);
}
}
catch(Exception e)
{System.out.println(e.getMessage());
}
}
}
Run Code Online (Sandbox Code Playgroud)
我得到一个 Html 文件作为 String First …
支持可嵌入的Java HTTP服务器时似乎存在多个极端情况.我已经看到了极简主义的方法,如NanoHTTPD,并利用com.sun.net.httpserver包试图嵌入Jetty和Tomcat.理想的可嵌入HTTP服务器将被实现,以便它可以通过Executor启动并带有Servlet/JSP支持,但是否则应允许使用其父级的记录器并允许集成其JMX钩子.
同样,它也应该是模块化的,您可以选择不包括某些功能.有没有人遇到过具有这种特性的任何基于Java的HTTP服务器?
当尝试在Spring-roo PostGres项目中创建实体时,我收到以下错误:
ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: operator does not exist: integer ~~ unknown
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 433
Run Code Online (Sandbox Code Playgroud)
可能是什么解决方案?
在哪个部分中,常量volatile变量存储在c.在微控制器中,我们应该将这种变量放在RAM中.对?
我有一些字符串:
new_account_notification
updated_account_notification
reactivated_account_notification
updated_billing_info_notification
Run Code Online (Sandbox Code Playgroud)
我想匹配这些字符串:
accountreactivated_accountbilling_info请建议正则表达式来满足这些条件.
我需要拆分以下字符串((OPERATING_CARRIER ='AB'或OPERATING_CARRIER ='AB'OR(OPERATING_CARRIER ='VA'AND(FLIGHT_NO = 604或FLIGHT_NO = 603)))):
OPERATING_CARRIER='AB'
OPERATING_CARRIER='AB'
OPERATING_CARRIER='VA'
FLIGHT_NO=604
FLIGHT_NO=603
Run Code Online (Sandbox Code Playgroud)
我尝试了下面这段代码
String syntax = "(OPERATING_CARRIER='AB' OR OPERATING_CARRIER='AB' OR (OPERATING_CARRIER='VA' AND (FLIGHT_NO=604 OR FLIGHT_NO=603)))";
List < String > matchList = new ArrayList < String > ();
Pattern regex = Pattern.compile("\\(([^)]*)\\)");
Matcher regexMatcher = regex.matcher(syntax);
while (regexMatcher.find())
{
matchList.add(regexMatcher.group(1));
System.out.println(regexMatcher.group(1));
}
Run Code Online (Sandbox Code Playgroud)
我得到的输出为OPERATING_CARRIER ='AB'或OPERATING_CARRIER ='AB'OR(OPERATING_CARRIER ='VA'AND(FLIGHT_NO = 604或FLIGHT_NO = 603)