小编Tri*_*ick的帖子

如何确定字符串是否已经过URL编码?

我怎么能检查字符串是否已被编码?

例如,如果我编码TEST==,我得到TEST%3D%3D.如果我再次编码最后一个字符串,我得到TEST%253D%253D,如果它已经编码,我必须知道它...

我已经保存了编码参数,我需要搜索它们.我不知道输入参数,它们是什么 - 编码与否,所以我必须知道在搜索之前是否必须对它们进行编码或解码.

java utf-8 url-encoding

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

PostMethod setRequestBody(String)已弃用 - 为什么?

我正在使用Apache Commons HttpClient PostMethod 3.1.

在PostMethod类中,还有三种设置POST方法请求体的方法:

setRequestBody(InputStream body)
setRequestBody(String body)
setRequestBody(NameValuePair[] parametersBody);
Run Code Online (Sandbox Code Playgroud)

NameValuePair API

不推荐使用前两种方法.有人知道为什么吗?因为如果我想将XML放到请求体中,NameValuePair对我没有帮助.

有人知道解决方法或解决方案吗?

java request apache-commons-httpclient

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

如何获取正在上载的文件的InputStream的MIME类型?

简单的问题:如何在InputStream不保存文件的情况下获取用户上传到我的servlet的文件的MIME类型(或内容类型)?

java servlets inputstream mime-types

25
推荐指数
3
解决办法
5万
查看次数

一步一步谷歌SSO(java)?

我在所有打开的浏览器标签中迷失了Google单点登录:)

我已经有一个应用程序,我想把它放在谷歌市场上.强制整合是Google SSO.我用Spring在Struts2上构建了应用程序.

所以现在我需要一些指导如何进行这种集成.一个例子是完美的.或者如何开始,使用哪种技术,最佳方法,类似的东西......

另外,我是否必须使用Google App Engine进行SSO集成?老实说,我很困惑:)

编辑

我从这里开始:developers.google.com/google-apps/marketplace/sso因为我使用Java,如果你看一下底部的入门,我想使用step2,但链接已经死了.从那以后我被卡住了......

这里的链接也已死亡.

java single-sign-on oauth-2.0

13
推荐指数
2
解决办法
6166
查看次数

FindBugs - 如何解决EQ_COMPARETO_USE_OBJECT_EQUALS

我在这里一无所知......

 1: private static class ForeignKeyConstraint implements Comparable<ForeignKeyConstraint> {
 2: String tableName;
 3: String fkFieldName;
 4: 
 5: public int compareTo(ForeignKeyConstraint o) {
 6:    if (this.tableName.compareTo(o.tableName) == 0) {
 7:            return this.fkFieldName.compareTo(o.fkFieldName);
 8:        }
 9:        return this.tableName.compareTo(o.tableName);
10:    }
11: }
Run Code Online (Sandbox Code Playgroud)

在第6行,我从FindBugs得到: Bug: net.blabla.SqlFixer$ForeignKeyConstraint defines compareTo(SqlFixer$ForeignKeyConstraint) and uses Object.equals()

链接到定义

我不知道如何纠正这个问题.

java findbugs compareto

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

响应输出流内容长度?

我正在通过各种方法写输出流.在关闭之前,我怎样才能找出输出流的内容长度?

java outputstream response

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

MissingResourceException - 找不到基本名称的包

我知道在stackoverflow和其他论坛上有很多关于这个错误的问题和答案.但我还是找不到解决方案......

出于速度原因,我有一个实用程序类,它根据提供的语言环境加载所有静态数据映射(例如几个月).

所以这个实用程序类看起来像这样:

public static final String GLOBAL_MESSAGES = "globalMessages";

private static Map<Integer,Month> monthsMap;

private ResourceBundle getResourceBundle(Locale locale) {
    ResourceBundle rb = ResourceBundle.getBundle(GLOBAL_MESSAGES, locale);
    return rb;
}

private Map<Integer,Month> getMonths() {
    if(monthsMap == null) {
        setMonths();
    }
    return monthsMap;
}

private void setMonths() {
    try {
        monthsMap = getFactory().getDAO().getAllMonths();
    } catch (SQLException e) {
        logger.error(e);
    } catch (EmptyResultException e) {
        logger.error(e);
    }
}

public Map<Integer,Month> getMonths(Locale locale) {
    if(locale == null) {
        return monthsMap;
    } else {
        if(this.locale != locale) …
Run Code Online (Sandbox Code Playgroud)

java locale bundle struts2 properties

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

Android ListActivity - 固定页眉和页脚

是否可以将ListActivity的页眉和页脚设置为固定在顶部和底部,因此只有内容(列表)滚动,而不是页眉和页脚?

我这两个都设置如下:

View header = getLayoutInflater().inflate(R.layout.list_header, null);
View footer = getLayoutInflater().inflate(R.layout.list_footer, null);
ListView listView = getListView();
listView.addHeaderView(header);
listView.addFooterView(footer);
Run Code Online (Sandbox Code Playgroud)

android header fixed footer listactivity

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

JiBX unmarshalling - 是否有可能告诉JiBX忽略元素的顺序?

有没有办法解决这个问题?

例如,我的XML:

<group>
    <idExt>new group idext</idExt>
    <user-id>1</user-id>
    <parent-id>2</parent-id>        
</group>
Run Code Online (Sandbox Code Playgroud)

当解组时,没有错误,但是当我改变顺序时:

<group>
    <user-id>1</user-id>
    <parent-id>2</parent-id>
    <idExt>new group idext</idExt>
</group>
Run Code Online (Sandbox Code Playgroud)

它失败了org.jibx.runtime.JiBXException: Expected "group" end tag, found "idExt" start tag (line 4, col 2).

我的解组(实现Struts2 ContentTypeHandler接口):

public void toObject(Reader in, Object target) {
    try {
        IBindingFactory bf = BindingDirectory.getFactory(target.getClass());
        IUnmarshallingContext umc = bf.createUnmarshallingContext(); 
        umc.setDocument(in); 
        // This un-conditional cast is the current way that JibX unmarshalls to an // already instantiated object - YUCK 
        ((IUnmarshallable)target).unmarshal(umc); 
    } catch (JiBXException e) {
        throw new RuntimeException(e); …
Run Code Online (Sandbox Code Playgroud)

java tags unmarshalling jibx

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

如何找出未使用的JAR应用程序?

在我们的应用程序中,通过开发大量JAR文件的过程已被收集.如何过滤掉那些应用程序不再使用的内容?在一些简单的方法?

java jar

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