此函数应该更改被单击对象的背景颜色
function colorMe(){
$(this).css('background-color', 'red');
}
Run Code Online (Sandbox Code Playgroud)
我这样称呼它
$('.colorme').click(colorMe);
Run Code Online (Sandbox Code Playgroud)
它改变了这个div的背景
<div class="colorme">Color Me</div>
Run Code Online (Sandbox Code Playgroud)
问题是我想在运行colorMe之前做一些其他事情.所以我不能只使用$('.colorme').click(colorMe);.我想要做的就是这样
$('.colorme').click(function(){
alert('something happens first, then colorMe is called');
colorMe(); //I call colorMe here..
$(this).colorMe(); //I also tried this, but it's not working
});
Run Code Online (Sandbox Code Playgroud)
但它并没有影响div.我认为它失去了影响div的轨道.我需要传递它吗?
是否可以在Java中使用两个具有相同名称但不同参数和返回类型的方法?看起来它是一个很好的方法来推广一个简单的getter和setter ..你可以用构造函数来做到这一点,为什么不使用常规方法?例如
为什么不能做..
int getVal() {
return int;
}
boolean getVal() {
return true;
}
setVal(int a) {
}
Run Code Online (Sandbox Code Playgroud)
和
setVal(boolean a) {
}
Run Code Online (Sandbox Code Playgroud) 我们有一个项目定义了它使用 XSD 文件生成的消息格式。
将这些 XSD 文件作为另一个项目的依赖项的最简单方法是什么?
我正在考虑使用maven-build-helper Attach-artifact目标来附加我的 XSD 文件。
有没有更好的机制?
有没有人知道可以根据正则表达式编辑密码的log4j或logback类?
写一个看起来微不足道,但只是想检查一下是否有一个?
谢谢.
更新:
从评论来看,这听起来不是一个明智的主意;-)
@麦克风:
新发展的好点.
虽然对于旧版应用程序,我们可能不想修改代码.
对于第三方库,我们可能无法修改代码.
@Thorbjorn:
例如,正则表达式可能是"<password>(.*?)</password>".
对于独立的Java应用程序,我们看到非常罕见的错误,其中包含有效XML内容的字符串导致JAXB抛出异常,例如:
javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException:
<Line 1, Column 129>: XML-20221: (Fatal Error) Invalid char in text.]
Run Code Online (Sandbox Code Playgroud)
这是一个非常古老的Java应用程序,它是为旧版本的Java编写的,我们有一个现有的依赖项:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>xdb-xmlparser</artifactId>
<version>10.2.0.3.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
错误代码始终是XML-20221,但原因可能有所不同,例如:
XML-20221: (Fatal Error) Invalid char in text.
XML-20100: (Fatal Error) Expected '?>'.]
XML-20121: (Fatal Error) End tag does not match start tag 'TotalDepositReqd'.
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪的其余部分也会有所不同,但通常看起来像:
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:415)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:284)
at oracle.xml.parser.v2.NonValidatingParser.parseEndTag(NonValidatingParser.java:1359)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1304)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:326)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:293)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:209)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)
Run Code Online (Sandbox Code Playgroud)
我们的Java版本是:
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build …Run Code Online (Sandbox Code Playgroud) 看来SpringSource可能正在改变托管其OSGI包的位置?
我们的Nexus存储库管理器定义了以下存储库:
但是,在尝试引用以下依赖项时,它们似乎不可用于其中任何一个?
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.jms</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
相反,这似乎是在一个新的位置:http://ebr.springsource.com/repository/app/bundle ??
希望有人可以对此有所了解.谢谢.
请赐教:
你更倾向哪个?为什么?[可读性?内存关注?其他一些问题?]
1.
String strSomething1 = someObject.getSomeProperties1();
strSomething1 = doSomeValidation(strSomething1);
String strSomething2 = someObject.getSomeProperties2();
strSomething2 = doSomeValidation(strSomething2);
String strSomeResult = strSomething1 + strSomething2;
someObject.setSomeProperties(strSomeResult);
Run Code Online (Sandbox Code Playgroud)
2.
someObject.setSomeProperties(doSomeValidation(someObject.getSomeProperties1()) +
doSomeValidation(someObject.getSomeProperties2()));
Run Code Online (Sandbox Code Playgroud)
如果你以其他方式做,那会是什么?你为什么这样做?
我们有一些自定义的subversion pre和post提交挂钩,可以在我们的生产服务器上正常工作.
对于开发人员测试,我使用的是cywgin.直到最近,提交钩子也正常工作.
但是,在运行cygwin更新后,钩子现在失败了(为了清晰起见,添加了换行符):
0 [main] svn 14820 child_info_fork::abort:
C:\cygwin\bin\cygcrypto-1.0.0.dll: Loaded to different address:
parent(0x440000) != child(0x590000)
Run Code Online (Sandbox Code Playgroud)
有没有人见过类似的东西?
有谁知道一个名称空间感知的xml解析器/ zipper?
我不想拉入一大堆轴或类似的库,而是希望解析以下内容:
(ns foo
(:require [clojure.zip :as zip]
[clojure.xml :as xml])
(:use clojure.data.zip.xml))
(def xml "<soap:Envelope xmlns=\"urn:WEBSERVICE-URN\"
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
<soap:Body>
<loginResponse>
<result>
<sessionKey>SESSION-KEY-HERE</sessionKey>
</result>
</loginResponse>
</soap:Body>
</soap:Envelope>")
(def root
(zip/xml-zip
(xml/parse
(java.io.ByteArrayInputStream. (.getBytes xml "UTF-8")))))
(def key (xml1-> root ???? ???? :loginResponse :result :sessionKey text))
Run Code Online (Sandbox Code Playgroud)
我似乎无法导航具有XML命名空间的xml元素?
我已经将一个java项目编译成一个Jar文件,并且在运行它时遇到了问题.
当我跑:
java -jar myJar.jar
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Could not find the main class: myClass
Run Code Online (Sandbox Code Playgroud)
类文件不在jar的根目录中,所以我尝试更改主类的路径以匹配类文件的路径,我得到了同样的问题.
我应该扁平化文件结构吗?如果是这样我该怎么做 如果有任何用途,我正在使用Ant来构建Jar文件.
UPDATE
这是jar的内容和相关的Ant部分,我已经将我工作的公司名称改为"org":
META-INF/
META-INF/MANIFEST.MF
dataAccessLayer/
dataAccessLayer/databaseTest.class
org/
org/eventService/
org/eventService/DatabaseObject.class
org/eventService/DatabaseObjectFactory.class
org/eventService/DbEventClientImpl$HearBeatMonitor.class
org/eventService/DbEventClientImpl.class
org/eventService/EmptyQueryListException.class
org/eventService/EventHandlerWorkItem.class
org/eventService/EventProcessor.class
org/eventService/EventTypeEnum.class
org/eventService/EventWorkQueue$MonitorThread.class
org/eventService/EventWorkQueue$PoolWorker.class
org/eventService/EventWorkQueue.class
org/eventService/FailedToLoadDriverException.class
org/eventService/IConnectionFailureListener.class
org/eventService/InvalidEventTypeException.class
org/eventService/JdbcInterfaceConnection.class
org/eventService/NullArgumentException.class
org/eventService/OracleDatabaseObject.class
org/eventService/ProactiveClientEventLogger.class
org/eventService/ProactiveClientEventLoggerException.class
org/eventService/PropertyMap.class
org/eventService/SQLServerDatabaseObject.class
org/eventService/TestHarness.class
org/eventService/Utilities.class
Run Code Online (Sandbox Code Playgroud)
而蚂蚁目标:
<target name="compile" depends="init" description="compile the source ">
<javac srcdir="src" destdir="bin" classpathref="project.class.path"/>
</target>
<target name="buildjar" description="build jar file" depends="compile">
<mkdir dir="dist"/>
<jar destfile="dist/myJar.jar" basedir="bin" includes="**/*.class" >
<manifest>
<attribute name="Main-Class" value="org.eventService.ProactiveClientEventLogger"/>
</manifest>
</jar>
</target>
Run Code Online (Sandbox Code Playgroud) java ×5
ant ×1
clojure ×1
coding-style ×1
cygwin ×1
jar ×1
javascript ×1
jaxb ×1
jquery ×1
log4j ×1
logback ×1
mainclass ×1
maven ×1
maven-2 ×1
optimization ×1
osgi-bundle ×1
refactoring ×1
soap ×1
spring ×1
svn ×1
xml ×1
xml-parsing ×1
xsd ×1