如何告诉类只包含NON_EMPTY和NON_NULL值,使用
@JsonInclude(Include.NON_NULL)
@JsonInclude(Include.NON_EMPTY)
public class foo{
String a;
}
Run Code Online (Sandbox Code Playgroud)
抛出重复注释的错误.
我想知道jdbi sql api处理sql查询究竟是什么用于调试目的.我的接口类如下
public inteface myinteface{
@SqlQuery("select :c1 from tablename where cond = :cd")
String returnMeValue(@Bind("c1") String c1, @Bind("cd") Integer cd);
}
Run Code Online (Sandbox Code Playgroud)
后来在另一个班级中称为 String result = myinterfaceclassobject.returnMeValue("Name",1);
我没有得到预期的答案,所以我想看看实际上是什么进入SQL查询.那么有什么方法可以获得最终处理的查询吗?
如何配置dropwizard以向用户提供自定义错误消息.如果我的函数应该返回一个对象myObject,但是由于存在错误,它应该抛出异常并使用自定义消息向User返回一个错误Object.
我有两个反应事件:
表单提交事件
sendMessage: function(event){
console.log(event);
event.preventDefault();
},
Run Code Online (Sandbox Code Playgroud)keyPress事件
textareaKeypress: function(event){
if (event.which == 13 && !event.shiftKey){
document.getElementById('messagebox').submit();
}
},
Run Code Online (Sandbox Code Playgroud)但reactJS没有捕获由触发的表单提交textareaKeypress
.如何通过适当的事件来呼叫sendMessage
来自textareaKeypress
?
我正在使用 java-ee websockets 实现一个小型聊天应用程序。
有一次,由于各种原因,我想关闭客户端的会话,以便关闭连接。
为了关闭连接,我调用了onClose
函数,并在该函数中调用了session.close()
但之后我收到以下错误:
java.lang.IllegalStateException: The WebSocket session has been closed and no method (apart from close()) may be called on a closed session
at org.apache.tomcat.websocket.WsSession.checkState(WsSession.java:643)
at org.apache.tomcat.websocket.WsSession.addMessageHandler(WsSession.java:168)
at org.apache.tomcat.websocket.pojo.PojoEndpointBase.doOnOpen(PojoEndpointBase.java:81)
at org.apache.tomcat.websocket.pojo.PojoEndpointServer.onOpen(PojoEndpointServer.java:70)
at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.init(WsHttpUpgradeHandler.java:129)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:629)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)
我不确定我做错了什么,也不知道为什么会出现这个异常。
我正在创建一个带聊天应用程序的python应用程序.聊天应用程序仅依赖于龙卷风.但聊天需要各种数据库访问,Django ORM做得很漂亮.我正在使用龙卷风websockets进行聊天.所以我有以下选择:
那么合并这两个框架的最佳方法应该是什么,这样它们都可以很好地工作,而不会有太多的变化和性能问题.
我对正则表达式非常有经验,但无法弄清楚为什么这不起作用.
我的示例文字:
{
"coord":
{
"lon":-74.01,
"lat":40.71
},
"sys":
{
"message":0.2452,
"country":"United States of America",
"sunrise":1394191161,
"sunset":1394232864
},
"weather":
[
{
"id":803,
"main":"Clouds",
"description":"broken clouds",
"icon":"04n"
}
],
"base":"cmc stations",
"main":
{
"temp":270.54,
"pressure":1035,
"humidity":53,
"temp_min":270.15,
"temp_max":271.15},
"wind":
{
"speed":2.1,
"deg":130},
"clouds":
{
"all":75
},
"dt":1394149980,
"id":5128581,
"name":"New York",
"cod":200
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想抓住weather[0].id
.
我的完整脚本(curl
获取JSON):
curl -s "http://api.openweathermap.org/data/2.5/weather?q=NYC,NY" 2>/dev/null | grep -e '"weather":.*?\[.*?\{.*?"id": ?\d{1,3}'
Run Code Online (Sandbox Code Playgroud)
我总是得到错误
grep: invalid repetition count(s)
Run Code Online (Sandbox Code Playgroud) 我正在nginx上设置反向代理.我有一个使用server_name的虚拟主机设置,phpmyadmin.lvh.me
我想重定向localhost/phpmyadmin
到phpmyadmin.lvh.me
反向代理.
这是我的默认配置文件:
upstream phpmyadmin {
server phpmyadmin.lvh.me:80;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location /phpmyadmin/ {
proxy_pass http://phpmyadmin;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
} …
Run Code Online (Sandbox Code Playgroud) 我在eclipse Luna中创建了一个动态Web项目,然后将其转换为maven项目.我指定了依赖项如下:
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1102-jdbc41</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
并且还更新了tomcat7插件
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<port>8080</port>
<path>/</path>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但经过mvn clean install
之后mvn tomcat7:run
我得到了以下错误:
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /home/dheerendra/workspace/myproject/src/main/webapp does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:140)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4906)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5086)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Oct 18, 2014 4:24:09 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error …
Run Code Online (Sandbox Code Playgroud) 在读取java man
页面时,我发现了-Dproperty=value
通过传递此标志的stats标志,它将创建一个value = value的系统属性.我写了一个测试java代码:
class File{
public static void main(String[] args){
System.out.println("HOLA");
System.out.println(System.getProperty("blah"));
}
}
Run Code Online (Sandbox Code Playgroud)
我编译相同,javac File.java
然后使用命令运行,java File -Dblah=blah
但我得到以下输出
HOLA
null
Run Code Online (Sandbox Code Playgroud)
然后我用as跑了java -Dblah=blah File
然后我得到了预期的输出:
HOLA
blah
Run Code Online (Sandbox Code Playgroud)
问题是:这是一个错误还是一个故意的行为.这似乎是一个错误,因为在大多数程序中,命令行无关紧要.
我想解析.tex文件的以下部分
\section{a}
some random lines with lot
of special characters
\subsection{aa}
somehthing here too
\section{b}
Run Code Online (Sandbox Code Playgroud)
我想要内容\section{a}
和\section{b}
包容性所以我在python中尝试了以下代码
import re
a="my tex string mentioned above"
b=re.findall(r'\\section{a}.*\\section{b}',a)
print(b)
Run Code Online (Sandbox Code Playgroud)
但我得到了b=[]
.哪里错了?
java ×6
python ×2
regex ×2
websocket ×2
annotations ×1
asynchronous ×1
bash ×1
command-line ×1
curl ×1
django ×1
dropwizard ×1
eclipse ×1
forms ×1
grep ×1
jackson ×1
jakarta-ee ×1
javascript ×1
jdbi ×1
json ×1
maven ×1
nginx ×1
proxy ×1
python-3.x ×1
reactjs ×1
shell ×1
sql ×1
sql-server ×1
tomcat7 ×1
tornado ×1
virtualhost ×1
web-project ×1