小编use*_*882的帖子

JAXB - 包含HTML页面的unmarshall元素

我使用JavaScript将页面源代码(document.getElementsByTagName('html')[0].innerHTML)发送到我的web服务元素中<pagesource>...</pagesource>.显然,那里有HTML标签,因此我在解组时遇到错误.有可能以某种方式解析这个或逃避所有坏人物吗?

ERROR

com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 52; columnNumber: 3; The element type "input" must be terminated by the matching end-tag "</input>".]
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:335)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:514)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:215)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:184)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:214)
at cz.fit.cvut.swe.pagerating.ws.WebService.addRating(WebService.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:43)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) …
Run Code Online (Sandbox Code Playgroud)

javascript java jaxb

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

JavaScript + Chrome标签页Api - 无法获取标签的网址

我有以下代码片段,问题是chrome.tabs.getSelected的回调是在使用空url发送的请求之后计算的.我怎么解决这个问题?

function send() {
var url = '';
chrome.tabs.getSelected(null, function(tab) {
    url = tab.url;
});

var client = new XMLHttpRequest();
client.onreadystatechange = function() {
    if(this.readyState == 4) {
        alert(this.status);
    }
}
client.open("POST", "http://myurl");
client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");

client.send(url);
}
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome google-chrome-extension

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

如何正确使用a4j:mediaOutput显示图像?

使用下面的代码我无法在网页中获取图像.我不确定我是否以正确的方式理解文档,并且我无法找到此代码的任何问题.

BEAN

@ManagedBean(name = "imageBean")
@RequestScoped
public class ImageBean {
    public void paint(OutputStream os, Object data) throws IOException {
        BinaryContent content = (BinaryContent) data;
        BufferedImage image = ImageIO.read(new ByteArrayInputStream(content.getContent()));
        ImageIO.write(image, "jpg", os);
    }
}
Run Code Online (Sandbox Code Playgroud)

PAGE

<rich:dataTable value="#{dataProviderBean.aoRequests}" var="item">
    <f:facet name="noData">No messages are available.</f:facet>
    ...
    <rich:column>
        <f:facet name="header">Image data</f:facet>
        <rich:list value="#{item.imageContents}" var="content">
            <a4j:mediaOutput element="img" cacheable="false" session="false"
                createContent="#{imageBean.paint}" value="#{content}" />
        </rich:list>
    </rich:column>
</rich:dataTable>
Run Code Online (Sandbox Code Playgroud)

java jsf richfaces

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

是否可以使用wget从网页下载PHP脚本?

如果我尝试wget <url>下载已解决的页面.但我想下载原始脚本.这可能吗?

linux http wget

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

Java,C,C++等中十进制数的精度

假设我们有这种循环(伪代码)

double d = 0.0
for i in 1..10 {
    d = d + 0.1
    print(d)
}
Run Code Online (Sandbox Code Playgroud)

在C与printf("%f", d)我得到这个:

0.100000
0.200000
0.300000
...
1.000000
Run Code Online (Sandbox Code Playgroud)

在C++中,cout << d我得到了这个:

0.1
0.2
...
1
Run Code Online (Sandbox Code Playgroud)

在Java中,System.out.println(d)我得到了这个:

0.1
0.2
0.3 (in debug mode, I see 0.30000000000004 there but it prints 0.3)
...
0.7
0.799999999999999
0.899999999999999
0.999999999999999
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:

  1. 为什么这个简单的代码用Java打印得如此糟糕且在C中是否正确?
  2. 这在其他语言中如何表现?

c c++ java decimal decimal-point

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

有没有比保留相同功能的三个嵌套地图更好的解决方案?

情况就是这样

private Map<String, Map<String, Map<String, String>>> properties;
Run Code Online (Sandbox Code Playgroud)

我想要访问所有级别 - 获取Map<String, Map<String, String>>,Map<String, String>或者只是String从内部地图.

这可以用更好的方式来避免这种嵌套结构吗?创建一个隐藏实现并提供简单方法的包装器是显而易见的解决方案,但它只是隐藏了主要问题.

java collections data-structures

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

如何确保随机数是唯一的而不是重复的?

我有一个生成随机数的简单代码

SecureRandom random = new SecureRandom();
...
public int getRandomNumber(int maxValue) {
    return random.nextInt(maxValue);
}
Run Code Online (Sandbox Code Playgroud)

上面的方法被调用大约10次(不是循环).我想确保所有数字都是唯一的(假设maxValue > 1000).

我可以确定每次打电话都会得到唯一的号码吗?如果没有,我该如何解决?

编辑:我可能含糊地说.我想避免手动检查,如果我真的有唯一的数字,所以我想知道是否有更好的解决方案.

java random unique

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

XSL-FO - 如何生成目录?

我有以下文档结构,我想生成一个适合我的XSLT转换的目录.我尝试了很多东西,但没有一个能为我工作.有人可以帮帮我吗?

通过以下转换,我在此处获得此警告和空页码.

 WARNING: Page 2: Unresolved id reference "N65898" found.
Run Code Online (Sandbox Code Playgroud)

Document structure

<article>
    <chapter>
        <title>Chapter 1</title>
        <para>chapter 1 text</para>
        <sect1>
            <title>Section1 1.1</title>
            <para>text 1.1</para>
            <sect2>
                <title>Section2 1.1.1</title>
                <para>text 1.1.1</para>
            </sect2>
            <sect2>
                <title>Section2 1.1.2</title>
                <para>text 1.1.2</para>
            </sect2>
            <sect2>
                <title>Section2 1.1.3</title>
                <para>text 1.1.3</para>
            </sect2>
            <sect2>
                <title>Section2 1.1.4</title>
                <para>text 1.1.4</para>
            </sect2>
        </sect1>
        <sect1>
            <title>Section1 1.2</title>
            <sect2>
                <title>Section2 1.2.1</title>
            </sect2>
            <sect2>
                <title>Section2 1.2.2</title>
                <sect3>
                    <title>Section3 1.2.2.1</title>
                </sect3>
                <sect3>
                    <title>Section3 1.2.2.2</title>
                </sect3>
            </sect2>
        </sect1>
    </chapter>
    <chapter>
        <title>Chapter 2</title>
        <sect1>
            <title>Section1 2.1</title>
            <sect2>
                <title>Section2 2.1.1</title>
            </sect2> …
Run Code Online (Sandbox Code Playgroud)

xml xslt xsl-fo

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

jQuery .css不起作用

我有以下代码,它似乎根本不起作用.没有画边框.我有什么不对吗?(我正确包含了jQuery,因为使用它的其他部分可以工作)

<script>
$(document).ready(function() {
    $('#login').css({"border":"3px solid black"});
});
function setBorder() {
    $('#login').css({"border":"1px solid black"});
}
</script>
<div id="#login">
    <form>
        Username: <input type="text" /><input type="button" value="Log in" onclick="setBorder();"/>
    </form>
</div>
Run Code Online (Sandbox Code Playgroud)

html javascript css

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

在存储保存和存储弹出后,修改的文件不会保持暂存状态

我有一堆分阶段的文件 - 其中一些是new file,其中一些是modified.我这样做git stash save "message",所有人都被藏起来了.没关系.但是,当我这样做时git stash pop,突然只有new file文件被上演,modified而不是.这是为什么?

git version-control

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

如何使用选择结果作为第二个选择的输入(如foreach)?

这是我想要实现的伪代码

part1 = select from foo ...
part2 = init empty
foreach row in part1
  part2 += select from foo where row.something as condition in here 
union part1, part2
Run Code Online (Sandbox Code Playgroud)

是否可以在一个查询中执行此操作?

这是结构

parent_name | name
------------+-------
null        | item1  # root
item1       | item2  # first level
item1       | item3  # first level
item2       | item4  # second level
item4       | item5  # third level
null        | item6  # another root
Run Code Online (Sandbox Code Playgroud)

结果 - 条件是我只想要root name = item1的树

parent_name | name
------------+------- …
Run Code Online (Sandbox Code Playgroud)

sql oracle

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

Ant错误:找不到引用$ {lib.classpath}

当我尝试使用ant构建项目时出现错误.这是构建文件:

<?xml version="1.0" encoding="UTF-8"?>
<project name="GPClient" default="dist" basedir=".">
    <description>
        simple example build file
    </description>
  <!-- set global properties for this build -->
  <dirname property="client.basedir" file="${ant.file.GPClient}"/>
  <property name="client.src" location="${client.basedir}/src"/>
  <property name="client.build" location="${client.basedir}/build"/>
  <property name="client.dist"  location="${client.basedir}/dist"/>
  <property name="client.done"  location="${client.basedir}/done"/>
  <property name="client.app"  location="${client.basedir}/app"/>
  <property name="client.webinf_classes" location="${client.basedir}/WEB-INF/classes"/>
  <property name="server.dir" location="${client.basedir}/../GrahamsProjServer"/>
  <property name="deploy.location"  location="${client.basedir}/../../jboss-as-7.1.1.Final/standalone/deployments"/>


    <path id="lib.classpath">
      <fileset dir="${client.basedir}">
          <include name="/lib/*.jar"/>
          <!-- <exclude name="jboss-servlet-api_3.0_spec-1.0.0.Final.jar" /> -->
      </fileset>
      <!-- <fileset dir="${client.basedir}/properties">
         <include name="*.properties"/>
     </fileset>
     <fileset dir="${server.dir}/dist">
         <include name="*.jar"/>
     </fileset>
     <fileset dir="${client.basedir}/WEB-INF/lib">
         <include name="*.jar"/>
     </fileset> -->
    </path>

    <path …
Run Code Online (Sandbox Code Playgroud)

xml ant

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

如何在加载时在TextArea中显示文本?

如何在程序运行时在textarea内显示加载文本?目前,文本显示在ActionPerformed上,但我希望它显示程序运行的时间.

java user-interface swing textarea awt

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