小编Gre*_*egD的帖子

SonarQube - Java规则"S128" - 为什么规则会抱怨在显然没有必要时会丢失break语句?

我无法弄清楚为什么Sonar一直在抱怨我"没有休息声明"的事实,即使它不需要......

我的开关:

    public static String lookupVoyageId(String referenceNumber, String sender) {
    switch (sender) {
        case "400_HGENT":
        case "200_HAPEN":
        case "500_HOOST":
            Preconditions.checkArgument(referenceNumber.contains("-"));
            return referenceNumber.split("-")[0];
        case "600_HZEEB":
            Preconditions.checkArgument(referenceNumber.length() >= 6);
            return referenceNumber.substring(0, 6);
        case "800_BVL":
            throw new TransferException("This reference number for IBIS isn't according to the requirements. Can't implement it yet.");
        case "MCCD":
            throw new TransferException("This reference number for MCCD isn't according to the requirements. Can't implement it yet.");
        default:
            throw new TransferException("The sender (" + sender + ") couldn't be identified.");
    } …
Run Code Online (Sandbox Code Playgroud)

java sonarqube

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

对IE8使用media ="print"

<link rel="stylesheet" href="printStyle.css" media="print" />
Run Code Online (Sandbox Code Playgroud)

这一行修复了Chrome/IE7和IE9的打印预览,但它似乎不适用于IE8 ..有没有人有任何想法?

经过一些评论后,我意识到这是一个IE8问题.我一直在逛逛,想出了在我的部分顶部添加以下内容:

<!--[if lt IE 9]>
    <script src="http://html5shiv-printshiv.googlecode.com/svn/trunk/html5shiv-printshiv.js"></script>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)

这使得可以使用通用样式表@media print {}.

这再次适用于IE7/9而不是IE8 ..再也不能真正找出原因.但printhiv确实有效,否则我无法在IE7中获得正确的打印预览.

html css printing internet-explorer internet-explorer-8

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

在 wsdl 文件中找不到 wsdl 绑定

我有以下 wsdl 文件:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.minfin.fgov.be/bbf/extern/myMinfin/"   xmlns="http://www.minfin.fgov.be/bbf/extern/myMinfin" xmlns:pols="http://www.minfin.fgov.be/bbf/extern/myMinfin/policies"

xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<wsdl:types>
<xsd:schema targetNamespace="http://www.minfin.fgov.be/bbf/extern/myMinfin/">
  <xsd:import namespace="http://www.minfin.fgov.be/bbf/extern/myMinfin/policies" schemaLocation="getPolicies.xsd" />
</xsd:schema>
</wsdl:types>

<wsdl:message name="policiesForPersonRequest">
  <wsdl:part name="policiesForPerson" element="pols:policiesForPersonRequest" />
</wsdl:message>

<wsdl:message name="policiesOutput">
  <wsdl:part name="policies" element="pols:policiesResponse" />
</wsdl:message>

<wsdl:portType name="MyMinfinService">
  <wsdl:operation name="getPoliciesForPerson">
    <wsdl:input message="policiesForPersonRequest" />
    <wsdl:output message="policiesOutput" />
  </wsdl:operation>
</wsdl:portType>

<wsdl:binding name="MyMinfinServiceHTTPBinding" type="MyMinfinService">
  <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
  <wsdl:operation name="getPoliciesForPerson">
    <wsdlsoap:operation soapAction="" />
    <wsdl:input>
      <wsdlsoap:body use="literal" />
    </wsdl:input>
    <wsdl:output>
      <wsdlsoap:body use="literal" />
    </wsdl:output>
  </wsdl:operation>
</wsdl:binding>

<wsdl:service name="MyMinfinServicePorts">
  <wsdl:port binding="MyMinfinServiceHTTPBinding" name="MyMinfinService">
    <wsdlsoap:address location="http://localhost:7001/bbf/MyMinfinService" /> …
Run Code Online (Sandbox Code Playgroud)

java soap wsdl

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

使用AJAX更新JSF/Primefaces数据表中的单行

在使用AJAX时,如何更新ap:datatable中的单行?

我不想更新整个数据表,因为它有很多行,这需要一些时间..

我的布局:

<h:form id="visitForm">
        <p:dataTable id="visitTable" var="visit" value="#{visitBean.findAllVisits()}">

            <p:column headerText="${msgs['email']}"
                <h:outputText value="#{visit.contactDetail.email}"/>
            </p:column>

            <p:column headerText="${msgs['clearance']}" id="clearance">
                <p:commandButton value="${msgs['clearance.ok']}"  actionListener="#{visitBean.makeClearanceNotOk(visit)}"/>
            </p:column>
        </p:dataTable>
    </h:form>
Run Code Online (Sandbox Code Playgroud)

我尝试了一些像update ="clearance"等的东西,但它似乎没有用.

我正在使用JSF 2.1和Primefaces 5.2

ajax datatable jsf primefaces

6
推荐指数
3
解决办法
8057
查看次数

FlatXmlDataSet空表(DBUnit)

是否可以验证数据库没有具有平坦xml结构的特定表的行?就像是:

<dataset>
   <TABLE/>
</dataset
Run Code Online (Sandbox Code Playgroud)

但这不起作用,因为我认为它只会验证"TABLE"是否存在.

我正在测试删除..

java dbunit integration-testing

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

JAXB - 带有 xsi:type 的编组

我对 jaxb 编组有点陌生,我正在尝试从我的对象中制作这个 xml:

<Process_Bericht_Result xsi:type="Type_Proces_Bericht_Result_v2"
xmlns="http://www.centralbrokersystem.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
   <Result_Data>
      ....
   </Result_Data>
</Process_Bericht_Result>
Run Code Online (Sandbox Code Playgroud)

我得到的是以下内容:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Proces_Bericht_result xmlns="http://www.centralbrokersystem.org">
    <Result_Data>
       ...
    </Result_Data>
</Proces_Bericht_result>
Run Code Online (Sandbox Code Playgroud)

我想定义 xsi:type...

我使用以下代码创建这些对象:

JAXBElement element = new JAXBElement(
            new QName("http://www.centralbrokersystem.org", "Proces_Bericht_Result"), TypeProcesBerichtResultV2.class, typeProcesBerichtResultV2);
Run Code Online (Sandbox Code Playgroud)

我必须创建一个 JAXBElement,因为 TypeProcesBerichtResultV2 类未使用 @RootElement 进行注释,并且它是使用 jaxB maven 插件生成的,因此我无法更改它。

然后我调用一个方法:

XmlUtils.object2Xml(element, TypeProcesBerichtResultV2.class)
Run Code Online (Sandbox Code Playgroud)

该方法的实现是:

    public static String object2Xml(Object obj,
                                Class clazz)  {
    String marshalledObject = "";
    if (obj != null) {
        try {
            JAXBContext jc = JAXBContext.newInstance(clazz);
            Marshaller marshaller = jc.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
                    new Boolean(true));
            StringWriter …
Run Code Online (Sandbox Code Playgroud)

java xml jaxb

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

maven basedir - 用前斜杠替换反斜杠

我怎样才能用一个 \ 替换我的 basedir 到带有 \\ 的 basedir ?

我试过了:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
                <defaultLibBundleDir>APP-INF/lib</defaultLibBundleDir>
                <skinnyWars>true</skinnyWars>
                <version>6</version>
                <modules>
                    <webModule>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>ecad-application-ws-webservice</artifactId>
                        <bundleFileName>ecad-application-ws-webservice.war</bundleFileName>
                        <contextRoot>/ecad-ws/ecadservice</contextRoot>
                    </webModule>
                </modules>

               <source>
                    project.properties['basedir']=project.properties['basedir'].replace('\\','/');
               </source>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

但这并没有改变任何事情..有人还有其他想法吗?

java maven

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

默认为h:selectOneMenu和jsf

我正在尝试为我的h:selectOneMenu设置默认值,但由于某种原因,第一项(见下文)不是第一项选择.第3项是"默认选择"项目.

<h:selectOneMenu value="#{bookBean.discountPercentage}">
    <f:selectItem itemLabel="Please select a value: " noSelectionOption="true" />
    <f:selectItems value="#{bookBean.paymentMethods}" var="paymentMethod"
                   itemValue="#{paymentMethod.discountPercentage}"
                   itemLabel="#{paymentMethod}" required="true"/>
    <f:ajax listener="#{bookBean.setDiscountValue}"/>
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)

因此,"请选择一个值"必须是列表中的第一项(它是),并且在打开te页面时必须是选定的值,而不是.

jsf selectonemenu jsf-2

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

在表中创建仅包含自动生成的字段的行 - SQL

我有下表:

CREATE TABLE "MIGRATION"."VERSION"
(
ID BIGINT PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY,
VERSION_DATE timestamp DEFAULT CURRENT TIMESTAMP NOT NULL
)
Run Code Online (Sandbox Code Playgroud)

我想在该表中插入一个"新行"但由于所有内容都是自动生成的,我该怎么办呢?

INSERT INTO "MIGRATION"."VERSION" VALUES();
Run Code Online (Sandbox Code Playgroud)

不工作.必须这样做,不能改变.

sql db2

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

切换行为 - java

为什么以下代码不会抛出runtimeException?

public class Test2 extends Test {


public static void main(String[] args) {
    char[] array = new char[]{'A', '\t', 'e', 'I', 'O', 'u', '\n', 'p'};

    int count = 0;
    for (char c : array) {
        switch (c) {
            case 'A':
                continue;
            case 'E':
                count++;
                break;
            case 'I':
                count++;
                continue;
            case 'o':
                break;
            case 'u':
                count++;
                continue;
        }
    }
    System.out.println("length of array: " + array.length);
    System.out.println("count= " + count);
}
Run Code Online (Sandbox Code Playgroud)

}

注意'E'和'e'不相等而且它在开关中..对'p'也一样.它确实编译并运行en print:数组的长度:8 count = 2

我今天完成了我的OCA证书并得到了上述问题.但是当我检查'e'或'p'时,我无法弄清楚它为什么不抛出运行时..这意味着每个开关中都有一个空的"默认"或什么?

java switch-statement

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

对于不同的PDF,MD5始终相同

我需要从PDF文件计算MD5,似乎每个文件都有相同的MD5:'d41d8cd98f00b204e9800998ecf8427e'.

md5计算适用于:word和txt文档.它对图像也有相同的行为. - >为任何图像生成的md5与上面pdf中的md5相同.

我唯一要做的是:

String md5 = DigestUtils.md5Hex(file.getInputStream());
Run Code Online (Sandbox Code Playgroud)

出于测试目的,我使用inputStream生成一个文件,并生成了正确的文件(带有内容),因此它不像inputStream是空的或者其他东西.

java md5

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