小编pak*_*ore的帖子

防止同一对象与hibernate中的两个不同会话相关联

使用jsf 1.2,hibernate,richfaces 3.3.0GA和facelets.

我在我的支持bean中有这个代码:

public List<Rater> getFreeRaters(){
    GP myGP = (GP) user;
    update(myGP.getContract());
    ArrayList<Rater> raters = new ArrayList<Rater>(myGP.getContract().getRaters());
    ArrayList<Rater> selectedRaters = this.getSelectedRaters();
    raters.removeAll(selectedRaters);
    return raters;

}
Run Code Online (Sandbox Code Playgroud)

这个用户界面的代码:

<a4j:form id="gradersForm" ajaxSingle="true">
    <rich:listShuttle sourceValue="#{user.gradersTab.freeRaters}" id="gradersTab_listShuttle"
    targetValue="#{user.gradersTab.selectedRaters}" var="rater" listsHeight="150"
        sourceListWidth="130" targetListWidth="130" sourceCaptionLabel="Available Items"
        targetCaptionLabel="Currently Active Items" > 
        <rich:column>
            <h:outputText value="#{rater.username}"></h:outputText>
        </rich:column>
    </rich:listShuttle>         
    <a4j:commandButton value="Save"></a4j:commandButton>

</a4j:form>
Run Code Online (Sandbox Code Playgroud)

这是我的会话过滤器:

public class HibernateSessionRequestFilter implements Filter {

private static Log log = LogFactory.getLog(HibernateSessionRequestFilter.class);

private SessionFactory sf;

public void doFilter(ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
        throws IOException, ServletException { …
Run Code Online (Sandbox Code Playgroud)

java session hibernate

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

可重入和递归

说每个递归函数都需要是可重入的,这是一个真实的陈述吗?

recursion reentrancy

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

如何规避Java编译中的"方法太大"错误?

我有一个用bigloo scheme函数语言编写的解析器,我需要编译成java类.整个解析器都是作为单个函数编写的.不幸的是,这导致JVM编译器抛出"Method too large"警告,然后在localvar中给出"far label"错误.有什么方法可以绕过这个错误吗?我在某处读到了关于DontCompileHugeMethods选项,它有用吗?拆分功能对我来说似乎不是一个可行的选择:( !!

java bigloo

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

使用Log4j的每个用户的不同日志

我有一个web应用程序,我想为每个用户使用不同的日志,因此我可以拥有用户在系统上所做的"历史记录".

这是我到目前为止:

import java.io.File;
import java.io.IOException;

import org.apache.log4j.DailyRollingFileAppender;
import org.apache.log4j.FileAppender;
import org.apache.log4j.SimpleLayout;
import org.apache.log4j.Logger;

public class LogManager {

    public Logger getLog(String username) throws IOException{
        SimpleLayout layout = new SimpleLayout(); 
        FileAppender appender = new DailyRollingFileAppender(layout, "users"+File.pathSeparator+username+File.pathSeparator+username, "'.'yyyy-MM");

        // configure the appender here, with file location, etc
        appender.activateOptions();
        Logger logger = Logger.getRootLogger();
        logger.addAppender(appender);
        return logger;
    }

}
Run Code Online (Sandbox Code Playgroud)

问题是,作为一个web应用程序,是多线程的,所以AFAIK我不能一直使用RootLogger并根据我正在登录的用户更改appender.我想我应该Logger为每个用户创建不同的,但这是正确的吗?

java log4j web-applications

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

没有Accept标头的AWS API Gateway二进制输出

根据http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html

If contentHandling is not defined, and if the Content-Type header of the response and the Accept header of the original request match an entry of the binaryMediaTypes list, API Gateway passes through the body. This occurs when the Content-Type header and the Accept header are the same; otherwise, API Gateway converts the response body to the type specified in the Accept header.

我无法发出原始请求发送Accept标头.如何让我的AWS API Gateway以二进制格式返回?(图像/ JPEG).因为我从s3发回的图像在最后一个阶段被转换为文本(因为原始请求缺少Accept: image/jpeg标题).

binary header http amazon-web-services aws-api-gateway

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

图像视口与放大Javascript

我想在html页面的视口中显示一个巨大的图像.我希望能够拖放图像以将其移动到视口内,就像在谷歌地图中一样.

我能找到这样的组件的库吗?

提前致谢

html javascript css drag-and-drop

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