为什么imho缺少"case"缩进 - switch语句中的关键字被认为是好的风格?
没有"case"关键字的缩进似乎是关于每个IDE的默认格式化选项:
switch (i){
case 0:
break;
case 1:
break;
}
Run Code Online (Sandbox Code Playgroud)
虽然我发现这种格式更直观:
switch (i){
case 0:
break;
case 1:
break;
}
Run Code Online (Sandbox Code Playgroud)
这背后有一些逻辑吗,这让我望而却步?
在@PostConstruct文档中,它描述了带注释的方法:
"该方法绝不能抛出已检查的异常."
如何处理例如可以在这种方法中抛出的IOException?只需将其包装在RuntimeException中,让用户担心对象的错误初始状态?或者@PostConstruct是错误的地方来验证和初始化注入了依赖项的对象?
我有以下JSP:
<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page isELIgnored="false"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><c:out value="${it.title}"/></title>
</head>
<body>
<c:forEach var="speaker" items="${it.speakers}" varStatus="stat">
<ul>
<li><c:out value="${speaker.person.firstName}" /> <c:out value="${speaker.person.lastName}" />, <c:out value="${speaker.person.address.city.zip}" /> <c:out value="${speaker.person.address.city.name}" /></li>
</ul>
</c:forEach>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Eclipse在我的代码中警告我关于EL表达式的每个实例:
Warning [line 10]: "value" does not support runtime expressions
Warning [line 13]: "items" does not support runtime expressions
...
Run Code Online (Sandbox Code Playgroud)
但事实并非如此,EL会被服务器正确评估.
任何人都可以向我暗示正确的方向为什么eclipse会警告我那些EL表达式?
为什么"git add"和"git commit"之间存在暂存区域?我理解这个概念,但是在实际提交之前没有看到将文件添加到临时区域的意义.为什么不跳过这一步呢?
由于历史原因,我们在不同的git存储库中有不同版本的源代码.因此,当项目A持有源项目B的版本X时,项目B保存源的版本Y.
你们知道将项目B作为项目A的一个分支导入的方法吗?
谢谢
有没有办法在Jersey资源中重定向用户代理?
在Spring MVC中有"redirect:" - 语法,但我在Jersey的Viewable课堂上找不到任何可比性.我发现工作的唯一方法是使用HttpServletResponse.sendRedirect().
我目前正在努力整合基于Jersey和Spring的REST服务.我正在使用Spring 3.0.2-RELEASE和jersey-spring 1.2.
但是jersey-spring为我的项目添加了对Spring 2.5.6的依赖,这导致与3.0.2-RELEASE的冲突给了我一个错误:
11:58:25,409 ERROR org.springframework.web.context.ContextLoader:215 - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [cloverjazz-web-context.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.getLocalName(Lorg/w3c/dom/Node;)Ljava/lang/String;
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
Run Code Online (Sandbox Code Playgroud)
有办法解决这个问题吗?有人知道吗?
谢谢!
有没有更好的方法从枚举元素创建数组:
public static enum LOGICAL {
AND ("&", "AND"),
OR ("||", "OR");
public final String symbol;
public final String label;
LOGICAL(String symbol, String label) {
this.symbol=symbol;
this.label=label;
}
}
public static final String[] LOGICAL_NAMES = new String[LOGICAL.values().length];
static{
for(int i=0; i<LOGICAL.values().length; i++)
LOGICAL_NAMES[i]=LOGICAL.values()[i].symbol;
}
public static final String[] LOGICAL_LABELS = new String[LOGICAL.values().length];
static{
for(int i=0; i<LOGICAL.values().length; i++)
LOGICAL_LABELS[i]=LOGICAL.values()[i].label;
}
Run Code Online (Sandbox Code Playgroud) site-deploy当我在调用release:perform目标时,我试图让wagon插件在生命周期中上传文件时,我有一个奇怪的问题.似乎wagon在im调用时正确上传文件,mvn site-deploy但它只是响应
无需上传
当调用mvn release:perform哪个应该调用site site-deploy文档中所述的阶段时.
这是旅行车的插件配置.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>upload-jars</id>
<phase>deploy site-deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromDir>target/checkout/target</fromDir>
<includes>*.jar</includes>
<url>scpexe://nohost.com</url>
<toDir>/var/www/projects/test</toDir>
<serverId>server - projects</serverId>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
maven告诉我正确的目标已经开始:
[INFO] Executing goals 'deploy site-deploy'...
[INFO] [INFO] Scanning for projects...
Run Code Online (Sandbox Code Playgroud)
但是旅行车没有上传任何东西:
[INFO] [INFO] --- wagon-maven-plugin:1.0-beta-3:upload (default) @ exp4j ---
[INFO] [INFO] Nothing to upload.
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
Run Code Online (Sandbox Code Playgroud)
是否有人发现我的问题导致maven在调用site-deploy时按预期工作但在执行时失败release:perform?