小编Pan*_*her的帖子

是强制实用类应该是final和private构造函数吗?

通过创建私有构造函数,我们可以避免从外部的任何地方实例化类.通过使类最终,没有其他类可以扩展它.为什么Util类需要private构造函数和final类?

java coding-style final private

9
推荐指数
2
解决办法
5766
查看次数

如何使用Rest Template强制TLS1.2到Rest客户端

我通过调用post方法使用Spring3.0 restTemplate来使用json webservice.

        MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>();
        headers.add("Content-Type", MediaType.APPLICATION_JSON_VALUE);      
        HttpEntity<Object> entity = new HttpEntity<Object>(requestAsString, headers);
        postForObject = restTemplate.postForObject(url, entity, responseClass );
Run Code Online (Sandbox Code Playgroud)

我们的应用程序部署在WAS服务器中,并尝试通过创建与TLS1.0的套接字连接来连接生产者.但是,现在生产者只支持TLS1.1和TLS1.2.

如何强制restTempate使用TLS1.1或TLS 1.2.

通常对于apache httpclient代码,创建自定义ProtocolSocketFactory并覆盖createSocket方法.但是,在RestTemplate的情况下,如何实现相同.

java spring resttemplate tls1.2

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

如何创建仅接受pdf和doc的文件字段

我需要使用输入类型文件只接受pdf和doc文件.

<input type="file" id="test" name="test" accept="application/msword,text/plain, application/pdf"/>
Run Code Online (Sandbox Code Playgroud)

这是在Windows中工作,但在ubunthu中,它只接受pdf文件

html cross-platform http-accept-language

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

无法在eclipse中导入凌空库

我刚刚从下面的链接获得了凌空图书馆.. git clone- https://android.googlesource.com/platform/frameworks/volley 在eclipse我正在按照步骤 导入> git>项目从git> ....等

并且库已在C:\ Users\active\git\volley中下载

当我只想将volley文件夹导入eclipse(C:\ Users\active\git\volley)时,它在IMPORT PROJECT中显示" 选择至少一个项目 ".他们只是一个项目,虽然我选择了它仍然是在顶部显示相同的错误..非常需要帮助...在此先感谢

eclipse git android

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

如何通过内置的JUnit测试自动连接服务

如何仅通过使用弹簧注释在测试类中自动装配服务

当我尝试以下错误时,在UserServiceImp类中使用@Service批注

2014-12-20 15:35:52错误TestContextManager:334-允许TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@5af97850]准备测试实例[com.amsb.bariz.base.test]时捕获了异常。 UserTest @ 4520ebad] org.springframework.beans.factory.BeanCreationException:创建名称为'com.amsb.bariz.base.test.UserTest'的bean时出错:自动连接依赖项的注入失败;嵌套的异常是org.springframework.beans.factory.BeanCreationException:无法自动连线字段:public com.amsb.bariz.base.service.UserService com.amsb.bariz.base.test.UserTest.userService; 嵌套的异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有找到类型为[com.amsb.bariz.base.service.UserService]的合格Bean作为依赖项:期望至少有1个bean符合此依赖项的自动装配条件。依赖项注释:{@ org.springframework.beans.factory.annotation.Autowired(required = true)}

我的服务等级是

package com.amsb.bariz.base.service.imp;

import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.amsb.bariz.base.dao.UserDao;
import com.amsb.bariz.base.dao.UserRoleDao;
import com.amsb.bariz.base.entity.User;
import com.amsb.bariz.base.entity.UserRole;
import com.amsb.bariz.base.service.UserService;


@Service("userService")
public class UserServiceImp implements UserService {

    @Autowired
    private UserDao userDao;

    @Autowired
    private UserRoleDao userRoleDao;

    public void register(User user) {

        PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();

        user.setPassword(passwordEncoder.encode(user.getPassword()));
        Calendar calendar = Calendar.getInstance();
        java.util.Date now = calendar.getTime();

        Date dateNow …
Run Code Online (Sandbox Code Playgroud)

java junit spring autowired spring-annotations

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

使用 RestTemplate 将 E 等特殊字符传递给 JSON Web 服务

我正在从数据库获取数据并调用其余的 json web 服务。我正在使用 spring RestTemplate 来调用 Web 服务。我添加了 jackson jar,spring 使用它来创建 json。\n但是,当我们得到像拉丁 e 这样带有尖锐 \xc3\x89 的字符时,我遇到问题。Jackson 没有转义它并按原样通过,这里 web 服务在另一端失败,给出 500 内部错误。我需要传递它的 unicode,如 \\u0209。\n我尝试使用 StringEcapeUtils 来转换它,它被转换为 \\u0209。\n但这一次RestTemplate再次将其转义为 \\u0209,并且在目标系统上以 \\u0209 形式接收。

\n\n

目标系统是另一个我们无法更改任何内容的系统。

\n\n

我的restTemplate 代码是:-

\n\n
MultiValueMap<String, String> headers =\n        new LinkedMultiValueMap<String, String>();\n        headers.add("Content-Type", MediaType.APPLICATION_JSON_VALUE); //Note Content-Type as opposed to Accept\n\n        HttpEntity<Object> entity = new HttpEntity<Object>(myRequest, headers);\n\n        myResponse = restTemplate.postForObject(url, entity, responseClass );\n
Run Code Online (Sandbox Code Playgroud)\n

spring json special-characters jackson resttemplate

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

如何在Spring Boot Starter测试中应用两个@RunWith

我正在使用Spring Boot Starter Test编写JUnit测试用例。我很想使用JunitParamrunner,它可以方便地传递文件以进行参数化测试。基本上,它逐行从文件中读取数据,并且每行都调用一个测试用例。问题是同时使用SpringJUnit4ClassRunner和JUnitParamsRunner都需要传递@RunWith。我不知道该怎么做。谁能提供一些线索。

java junit4 parameterized-tests spring-boot junitparams

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

允许正则表达式中的数字,包括负数

我写了这个正则表达式来删除任何不是数字的东西.

     var dataTest = data.replace(/[^0-9]/gi, '');
Run Code Online (Sandbox Code Playgroud)

它将"abc123xyz"转换为"123"

但是现在我想要覆盖负数: -

      var dataTest = data.replace(/[^-0-9]/gi, ''); 
Run Code Online (Sandbox Code Playgroud)

但它允许 - 介于两者之间.它将"abc123-xyz"转换为"123-"我希望它转换为"123"

但是,如果用户给出"-123abc",则应更改为"-123".

我在javascript中调用focusout事件上的代码.我也会在jquery中接受解决方案.

javascript regex jquery negative-number

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

为什么表示数字的String的Integer.parseInt会在J2ME中抛出java.lang.NumberFormatException?

我想总结一下四列的值recordstore.在这四个列中的值与数字decimal point,例如30.00; 该recordstore行是一个csv-like数据,我用它来使用用户定义的函数来获取特定列的值:例如,我获得了String四列的a "30.00".现在我想要sum这四个值; 所以我必须convert进去int!但是当我尝试使用时,Integer.parseInt就会java.lang.NumberFormatException被提升!那么如何在这种情况下做出总和呢?

java string numbers

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

将数据从 alertDialog 发送回活动

大家好,需要一些帮助,我创建了一个自定义警报对话框,它接受用户输入,如用户名和密码。我关注了 android 开发者网站我想要做的是一旦用户输入用户名和密码并按下警报对话框中的登录按钮,我想向创建对话框的活动显示这些值。我被困在这浪费了 3 个小时。任何帮助将非常感激。这是我的代码。

主活动.java

public class MainActivity extends FragmentActivity implements NoticeDialogFragment.NoticeDialogListener{

private Button dialogButton;
private Button customDialogButton;
private TextView customDialogTextview;

private Button dialogWithInterface;
private EditText dialogUsername;
private EditText dialogPassword;
String username;
String password;


public void showNoticeDialog() {
    // Create an instance of the dialog fragment and show it
    DialogFragment dialog = new NoticeDialogFragment();
    dialog.show(getFragmentManager(), "NoticeDialogFragment");

}



// The dialog fragment receives a reference to this Activity through the
// Fragment.onAttach() callback, which it uses to call …
Run Code Online (Sandbox Code Playgroud)

java android android-alertdialog android-dialogfragment

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

如何使用javascript/jquery循环表?

我有一个像下面的代码块

<tbody class="society_list">
    <tr>
        <td>1</td>
        <td>Dummy</td>
        <td>Dummy</td>
        <td id="lol0">UPDATE THIS</td>
    </tr>
    <tr>
        .....
    </tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)

我想要做的是遍历整个表,找到带有id的td,获取该id的值,然后更新内部的html.我现在有什么(对不起,我很新,我仍然不知道该怎么做......)

function update(){
  var trs = document.querySelectorAll('.society_list tr');
  for(i=0;i<trs.length-1;i++){
    trs[i].find('td').each(function(){
      //I know I need to do something here but what's that.. 
    });
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript jquery traversal

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

.remove()无法在Internet Explorer中运行

此代码在Google Chrome中运行良好,但无法在Internet Explorer中使用:

document.getElementsByClassName('info')[i].remove();
Run Code Online (Sandbox Code Playgroud)

还有其他方法可以做同样的事情,还是可以.remove()在Internet Explorer中工作?

javascript jquery cross-browser

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