2

我正在尝试显示一个带有超链接的简单 div,x 如下所示: 在此处输入图像描述

所以,当我运行我的应用程序时,我看到了 div 但我没有看到x<a href tag 是我的代码:

<div class="success"><a href="#" class="close">&times;</a>status message here...</div>

当我查看页面的源代码时,这就是它呈现的内容:

<div id="ctl00_ctl00_ContentMain_ContentMain_employee_status" class="success" style="display:block;">status message here...</div>

然后我尝试了<asp:hyperlink....

 <div class="success" id="divStatus" visible="false" runat="server"><asp:HyperLink id="success" runat="server" CssClass="close" Text="&times;"></asp:HyperLink></div>

而且我仍然没有看到 href 标签,这里发生了什么以及为什么我无法提供<a href or <asp:hyperlnk tag任何线索?


当具有绑定文件的 DynamicClientFactory 创建 createClient() 时,发生异常

有人让我知道如何通过 DynamicClientFactory 使用绑定文件创建客户端对象。

这是我测试过的示例代码。它发生了异常。

String wsdlURL = "http://localhost/test?wsdl";
ClassLoader loader = Thread.currentThread().getContextClassLoader();
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
List<String> bindingFiles = new ArrayList<String>();
File bindingFile = new File("custom.xml");
try {
     bindingFiles.add(bindingFile.getCanonicalPath().toString());
} catch (IoException e) {
    e.printStackTrace();
}
Client client = factory.createClient(wsdlURL, loader, bindingFiles);

下面是custom.xml。

<bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    wsdlLocation="http://localhost/test?wsdl"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
    jaxb:version="2.0" jaxb:extensionBindingPrefixes="xjc"
    xmlns="http://java.sun.com/xml/ns/jaxws">
    <enableWrapperStyle>true</enableWrapperStyle>
    <jaxb:globalBindings>
        <xjc:simple/> 
    </jaxb:globalBindings>
</bindings>

当我在示例代码之上运行时,我得到了以下异常..

java.lang.reflect.UndeclaredThrowableException
    at $Proxy18.bind(Unknown Source)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:318)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:252)
    at DynamicWebServiceClient_test.test(DynamicWebServiceClient_test.java:93)
    at DynamicWebServiceClient_test.main(DynamicWebServiceClient_test.java:54)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:52)
    ... 5 more
Caused by: java.lang.reflect.UndeclaredThrowableException
    at $Proxy20.fatalError(Unknown Source)
    at com.sun.tools.internal.xjc.api.impl.s2j.SchemaCompilerImpl.fatalError(SchemaCompilerImpl.java:279)
    at com.sun.tools.internal.xjc.util.ErrorReceiverFilter.fatalError(ErrorReceiverFilter.java:71)
    at com.sun.xml.internal.xsom.impl.parser.ParserContext$2.fatalError(ParserContext.java:196)
    at com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx.unexpectedX(NGCCRuntimeEx.java:484)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCHandler.unexpectedEnterElement(NGCCHandler.java:179)
    at com.sun.xml.internal.xsom.impl.parser.state.Schema.enterElement(Schema.java:401)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.startElement(NGCCRuntime.java:243)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
    at com.sun.tools.internal.xjc.util.SubtreeCutter.startElement(SubtreeCutter.java:93)
    at com.sun.tools.internal.xjc.reader.ExtensionBindingChecker.startElement(ExtensionBindingChecker.java:133)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
    at com.sun.tools.internal.xjc.reader.xmlschema.parser.IncorrectNamespaceURIChecker.startElement(IncorrectNamespaceURIChecker.java:102)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
    at com.sun.tools.internal.xjc.reader.xmlschema.parser.CustomizationContextChecker.startElement(CustomizationContextChecker.java:177)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
    at com.sun.tools.internal.xjc.reader.internalizer.DOMForestScanner$LocationResolver.startElement(DOMForestScanner.java:130)
    at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:228)
    at com.sun.xml.internal.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:111)
    at com.sun.tools.internal.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:78)
    at com.sun.tools.internal.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:86)
    at com.sun.tools.internal.xjc.reader.internalizer.DOMForestParser.parse(DOMForestParser.java:88)
    at com.sun.tools.internal.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:251)
    at com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:326)
    at com.sun.xml.internal.xsom.impl.parser.ParserContext.parse(ParserContext.java:113)
    at com.sun.xml.internal.xsom.parser.XSOMParser.parse(XSOMParser.java:154)
    at com.sun.xml.internal.xsom.parser.XSOMParser.parse(XSOMParser.java:143)
    at com.sun.tools.internal.xjc.ModelLoader.createXSOM(ModelLoader.java:505)
    at com.sun.tools.internal.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:226)
    ... 10 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:52)
    ... 39 more
Caused by: java.lang.RuntimeException: Fatal error compiling schema from WSDL at {http://localhost/test?wsdl}: Unexpected <jaxws:bindings> appears at line 18 column 62
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory$InnerErrorListener.fatalError(DynamicClientFactory.java:739)
    ... 44 more
Caused by: org.xml.sax.SAXParseException: Unexpected <jaxws:bindings> appears at line 18 column 62
    at com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx.unexpectedX(NGCCRuntimeEx.java:477)
    ... 34 more
4

2 回答 2

1

我正在写 InnerHtml divSuccess.InnerHtml ="status message here...如果这是擦除其静态内容的情况,那么替代方案是什么?

如果divStatus包含要保留的控件,则可以通过使用 Literal 控件并将其添加到控件集合中来附加 HTML,例如:

var lit = new Literal();
lit.Text = "my text or <strong>html</strong>";
this.divStatus.Controls.Add(lit);

或者,您可以在内部 使用另一个控件divStatus并更改其内部 HTML:

<div id="divStatus" runat="server">
    <a id="lnk1">This is the link that we don't want to be removed.</a>
    <asp:Literal runat="server" id="litStatusHtml" />
</div>
于 2012-05-04T02:37:24.620 回答
0

这是我如何解决我的问题

divStatus.InnerHtml = "<a href='#' class='close'>&times;</a>" + "status message here...";
于 2012-05-04T02:55:30.300 回答