我有一个String列表:
List<String> listString = new ArrayList<String>();
listString.add("faq");
listString.add("general");
listString.add("contact");
Run Code Online (Sandbox Code Playgroud)
我在列表上做了一些处理,我想对这个列表进行排序,但我希望"general"始终以第一个位置结束.谢谢 ;)
我该怎么做才能在 java <5.0 .. 中模拟 enum 类型的类?
public final class Week {
private static final Day[] _week = {Day.MONDAY, Day.TUESDAY, Day.WEDNESDAY, Day.THURSDAY, Day.FRIDAY, Day.SATURDAY, Day.SUNDAY};
public static Day getDayOfWeek(final int index) {
if (index >= 1 && index <= 7) {
return _week[index - 1];
}
throw new IndexOutOfBoundsException("Invalid index [1..7]");
}
public static final class Day {
public static final Day MONDAY = new Day(1, "Monday");
public static final Day TUESDAY = new Day(2, "Tuesday");
public static final Day …Run Code Online (Sandbox Code Playgroud) 我有一个输入:
<div class="search-field search-field-date search-field-calendar ui-datepicker-calendar columns small-3">
<input type="text" data-ng-model="goDate"
placeholder="Date d'aller" data-mtx-datepicker data-mtx-maxdate="returnDate" data-mtx-time="horairesAller" />
</div>
Run Code Online (Sandbox Code Playgroud)

当我选择日期时,我有这个:

现在我想显示如下的多个信息:

当我选择日期时:

我不知道该怎么做.
是否可以在性能方面优化这些查询:
UPDATE PEOPLE
SET ID_STATE = CASE
WHEN ID_STATE = 2 THEN 9
WHEN ID_STATE = 3 THEN 9
WHEN ID_STATE = 7 THEN 8
WHEN ID_STATE = 8 THEN 9
ELSE 0
END
WHERE ID_STATE IN (2,3,7,8)
GO
UPDATE PEOPLE
SET ID_PRESI = CASE
WHEN ID_PRESI = 3 THEN NULL
WHEN ID_PRESI = 4 THEN NULL
ELSE 0
END
WHERE ID_PRESI IN (3,4)
GO
UPDATE STATE_FIC_STATE_PEOPLE
SET ID_STATE = CASE
WHEN ID_STATE = 2 THEN 9
WHEN ID_STATE = …Run Code Online (Sandbox Code Playgroud) 我有一个用户列表,我想从我的列表中删除id <3的用户
其实我这样做:
[...]
int pid1 = 1;
int pid2 = 2;
int pid3 = 3;
Predicate<Person> personPredicate1 = p-> p.getPid() == pid1;
Predicate<Person> personPredicate2 = p-> p.getPid() == pid2;
Predicate<Person> personPredicate3 = p-> p.getPid() == pid3;
list.removeIf(personPredicate1);
list.removeIf(personPredicate2);
list.removeIf(personPredicate3);
[...]
Run Code Online (Sandbox Code Playgroud)
我想我不使用正确的方法?
我刚冬眠,所以这个问题看起来很愚蠢。
我有两个表:
应用:
@Entity
@Table
public class Application extends BaseSimpleEntity {
@Column(nullable = false)
private String appID;
@OneToOne(cascade = CascadeType.ALL)
@Searcheable
private LocalizedString name;
...
Run Code Online (Sandbox Code Playgroud)
汇编:
@Table
@Entity
public class Compilation extends BaseSimpleEntity {
@Column(nullable = false)
private String uid;
@ManyToOne
private Application application;
@Column
private DateTime creationDate;
@Column
private DateTime finishDate;
@Column
private String path;
....
Run Code Online (Sandbox Code Playgroud)
我想获得与给定应用程序匹配的编译列表。
我做了以下查询:
@Query("FROM Compilation c WHERE c.Application.id = :applicationId")
List<Compilation> findValidCompialiton(@Param("applicationId") Long applicationId);
Run Code Online (Sandbox Code Playgroud)
但这是行不通的。
错误:
引起原因:org.hibernate.QueryException:无法解析属性:应用程序:xx.xx.xx.xx.xx.Compilation [FROM xx.xx.xx.xx.xx.xx.Compilation c WHERE c.Application.id =: applicationId]位于org.hibernate.QueryException.generateQueryException(QueryException.java:137)位于org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120)位于org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java …
在部署webapp时,我需要连接一些文件,目前这是通过ant任务实现的.我正在尝试使用以下内容在maven构建过程中运行此任务:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<move file="${project.build.directory}/${project.name}-${project.version}/WEB-INF/classes/log4j.dev.properties"
tofile="${project.build.directory}/${project.name}-${project.version}/WEB-INF/classes/log4j.properties" />
<move file="${project.build.directory}/${project.name}-${project.version}/WEB-INF/classes/hibernate.cfg.dev.xml"
tofile="${project.build.directory}/${project.name}-${project.version}/WEB-INF/classes/hibernate.cfg.xml" />
<delete>
<fileset dir="${project.build.directory}/${project.name}-${project.version}/WEB-INF/classes/"
includes="**/hibernate.cfg.*.xml" />
<fileset dir="${project.build.directory}/${project.name}-${project.version}/WEB-INF/classes/"
includes="**/log4j.*.properties" />
</delete>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
上述操作失败,因为文件尚未复制/删除到目标目录中.如果我将阶段设置为"package",则ant任务运行正常并且所有文件都被复制/删除,但是因为.war已经在运行ant目标之前构建了,所以没有任何帮助.
基本上,我需要在准备包阶段结束时运行我的蚂蚁目标.
看过生命周期参考我无法研究如何将更细粒度的目标暴露给antrun插件.
问题:如何实现这种情况?
在 Spring MVC 中进行验证时使用 @Pattern 注解,如下所示:
@Pattern(regexp = "???", message = "#i18n{obligatoire}")
@NotEmpty
private String stringTest;
Run Code Online (Sandbox Code Playgroud)
我只想排除&角色。 @Pattern(regexp = "^&")这是正确的 ?
我想生成一个随机的字母数字字符串.我想从我的字符串中排除一些字符
l,i,o和数字0
目前我有这个代码:
import org.apache.commons.lang.RandomStringUtils;
...
numberFile = RandomStringUtils.randomAlphanumeric( 5 );
Run Code Online (Sandbox Code Playgroud)