我使用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) 我有以下代码片段,问题是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) 使用下面的代码我无法在网页中获取图像.我不确定我是否以正确的方式理解文档,并且我无法找到此代码的任何问题.
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) 假设我们有这种循环(伪代码)
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)
所以我的问题是:
情况就是这样
private Map<String, Map<String, Map<String, String>>> properties;
Run Code Online (Sandbox Code Playgroud)
我想要访问所有级别 - 获取Map<String, Map<String, String>>,Map<String, String>或者只是String从内部地图.
这可以用更好的方式来避免这种嵌套结构吗?创建一个隐藏实现并提供简单方法的包装器是显而易见的解决方案,但它只是隐藏了主要问题.
我有一个生成随机数的简单代码
SecureRandom random = new SecureRandom();
...
public int getRandomNumber(int maxValue) {
return random.nextInt(maxValue);
}
Run Code Online (Sandbox Code Playgroud)
上面的方法被调用大约10次(不是循环).我想确保所有数字都是唯一的(假设maxValue > 1000).
我可以确定每次打电话都会得到唯一的号码吗?如果没有,我该如何解决?
编辑:我可能含糊地说.我想避免手动检查,如果我真的有唯一的数字,所以我想知道是否有更好的解决方案.
我有以下文档结构,我想生成一个适合我的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) 我有以下代码,它似乎根本不起作用.没有画边框.我有什么不对吗?(我正确包含了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) 我有一堆分阶段的文件 - 其中一些是new file,其中一些是modified.我这样做git stash save "message",所有人都被藏起来了.没关系.但是,当我这样做时git stash pop,突然只有new file文件被上演,modified而不是.这是为什么?
这是我想要实现的伪代码
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) 当我尝试使用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) 如何在程序运行时在textarea内显示加载文本?目前,文本显示在ActionPerformed上,但我希望它显示程序运行的时间.