public class Primitive {
void m(Number b, Number ... a) {} // widening, autoboxing->widening->varargs
void m(byte b, Number ... a) {} // unboxing, autoboxing->widening->varargs
public static void main(String[] args) {
Byte b = 12;
Primitive obj = new Primitive();
obj.m(b, 23);
}
}
Run Code Online (Sandbox Code Playgroud)
我已经搜索过并发现扩展优先级高于取消装箱,因此在上面的方法调用中,应该调用第一个方法,因为第二个参数对于两者都是相同的.但这不会发生.你可以解释一下吗?
以一对多关系(国家/地区->)为例.
国家(反面):
@OneToMany(mappedBy = "country", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
private List<StateTable> stateTableList=new ArrayList<StateTable>(0);
Run Code Online (Sandbox Code Playgroud)
StateTable(拥有方):
@JoinColumn(name = "country_id", referencedColumnName = "country_id")
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH})
private Country country;
Run Code Online (Sandbox Code Playgroud)
尝试更新StateTable活动数据库事务(JTA或资源本地)中的提供(分离)实体的方法:
public StateTable update(StateTable stateTable) {
// Getting the original state entity from the database.
StateTable oldState = entityManager.find(StateTable.class, stateTable.getStateId());
// Get hold of the original country (with countryId = 67, for example).
Country oldCountry = oldState.getCountry();
// Getting …Run Code Online (Sandbox Code Playgroud) 我一直在Java EE应用程序中使用Joda Time进行日期时间操作,其中关联客户端提交的日期时间的字符串表示已使用以下转换例程转换,然后将其提交到数据库,即在getAsObject()方法中. JSF转换器.
org.joda.time.format.DateTimeFormatter formatter = org.joda.time.format.DateTimeFormat.forPattern("dd-MMM-yyyy hh:mm:ss a Z").withZone(DateTimeZone.UTC);
DateTime dateTime = formatter.parseDateTime("05-Jan-2016 03:04:44 PM +0530");
System.out.println(formatter.print(dateTime));
Run Code Online (Sandbox Code Playgroud)
当地时区比UTC/ 提前5小时30分钟GMT.因此,转换为UTC应从使用Joda Time正确发生的日期时间中扣除5小时30分钟.它按预期显示以下输出.
05-Jan-2016 09:34:44 AM +0000
Run Code Online (Sandbox Code Playgroud)
► 已+0530取代时区偏移量,+05:30因为它取决于<p:calendar>以此格式提交区域偏移量.似乎不可能改变这种行为<p:calendar>(否则本身就不需要这个问题).
但是,如果尝试在Java 8中使用Java Time API,那么同样的事情就会被破坏.
java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter.ofPattern("dd-MMM-yyyy hh:mm:ss a Z").withZone(ZoneOffset.UTC);
ZonedDateTime dateTime = ZonedDateTime.parse("05-Jan-2016 03:04:44 PM +0530", formatter);
System.out.println(formatter.format(dateTime));
Run Code Online (Sandbox Code Playgroud)
它意外地显示以下错误输出.
05-Jan-2016 03:04:44 PM +0000
Run Code Online (Sandbox Code Playgroud)
显然,转换的日期时间不符合UTC它应该转换的日期时间.
它需要采用以下更改才能正常工作.
java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter.ofPattern("dd-MMM-yyyy hh:mm:ss a z").withZone(ZoneOffset.UTC); …Run Code Online (Sandbox Code Playgroud) 我收到以下错误...
Unsupported configuration attributes: [permitAll]
Run Code Online (Sandbox Code Playgroud)
添加....
<sec:intercept-url pattern="/nonsecure/**" access="permitAll" />
Run Code Online (Sandbox Code Playgroud)
我在使用Spring 2.5的Websphere上.
有人可以帮忙吗?
杰夫波特
将应用程序部署为EAR(使用1个EJB和1个WAR模块)与单独的模块有什么区别?我想使用GlassFish 3 Web配置文件,但它不支持EAR存档.我可以简单地将EJB和WAR用作单独的模块吗?还有其他选择吗?
我需要for在JSTL/EL中表示以下循环(在Java上下文中).
for (int i = 6; i <= 15; i++) {
System.out.print(i+"\t");
}
Run Code Online (Sandbox Code Playgroud)
它将显示以下输出.
6 7 8 9 10 11 12 13 14 15
Run Code Online (Sandbox Code Playgroud)
我怎样才能在JSTL/EL中做同样的事情?我对它没有确切的想法.我只想尝试以下方法.
<c:forEach begin="6" end="15" varStatus="loop">
<c:out value="${loop.count}"/>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
它显然会显示以下输出.
1 2 3 4 5 6 7 8 9 10
Run Code Online (Sandbox Code Playgroud)
这不是我想要的.我需要在6和15之间显示数字(即在指定范围之间).我需要在Web应用程序中使用这样的概念来实现分页.我可以用EL吗?
\t在这个声明System.out.print(i+"\t");中并不重要.
以下代码无法编译.
package varargspkg;
public class Main {
public static void test(int... i) {
for (int t = 0; t < i.length; t++) {
System.out.println(i[t]);
}
System.out.println("int");
}
public static void test(float... f) {
for (int t = 0; t < f.length; t++) {
System.out.println(f[t]);
}
System.out.println("float");
}
public static void main(String[] args) {
test(1, 2); //Compilation error here quoted as follows.
}
}
Run Code Online (Sandbox Code Playgroud)
发出编译时错误.
对于测试的引用是不明确的,varargspkg.Main中的方法test(int ...)和varargspkg中的方法test(float ...)匹配
这似乎是显而易见的,因为在方法调用的参数值test(1, 2);可以提升int以及float
如果任何一个或两个参数后缀为F或f,则编译.
但是,如果我们使用相应的包装器类型表示方法签名中的接收参数,如下所示 …
我正在尝试在以下环境中部署应用程序.
到目前为止我在application-context.xml文件中的配置如下.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="WebAppPU"/>
<!--<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true"/>
<property name="generateDdl" value="true"/>
<property name="databasePlatform" value="org.hibernate.dialect.HSQLDialect"/>
</bean>
</property>-->
</bean>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="testDAOService" class="admin.dao.TestDAO"/>
</beans>
Run Code Online (Sandbox Code Playgroud)
这可以正常工作,直到上面的xml文件中的注释行被取消注释.当这些行被取消注释时,我得到以下异常.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot create inner …Run Code Online (Sandbox Code Playgroud) 我有以下HTML/CSS代码,用于根据从数据库中检索的行数显示页面.
.paginate {
font-family:Arial,Helvetica,sans-serif;
padding:3px;
margin:3px;
}
.disableCurrentPage {
font-weight:bold;
background-color:#999;color:#FFF;
border:1px solid #999;
text-decoration:none;color:#FFF;
font-weight:bold;
}
.paging {
cursor: pointer;
background-color: transparent;border:1px solid #999;
text-decoration:none;
color:#9CC;
font-weight:bold;
}Run Code Online (Sandbox Code Playgroud)
<div class='paginate'>
<input type="submit" name="btnFirst" value="First"
class="disableCurrentPage" disabled="disabled"/>
<input type="submit" name="btnPrev" value="Previous" class="paging"/>
<input type="submit" name="btnPage" value="1"
class="disableCurrentPage" disabled="disabled"/>
<input type="submit" name="btnPage" value="2" class="paging"/>
<input type="submit" name="btnPage" value="3" class="paging"/>
<input type="submit" name="btnPage" value="4" class="paging"/>
<input type="submit" name="btnPage" value="5" class="paging"/>
<input type="submit" name="btnPage" value="6" class="paging"/>
<input type="submit" name="btnPage" value="7" class="paging"/>
<input type="submit" …Run Code Online (Sandbox Code Playgroud)什么是passJava中的Python ?我意识到我可以使用continue或不使用语句的主体来实现这种效果,但我喜欢pass发表声明.
java ×4
hibernate ×2
jpa ×2
overloading ×2
spring ×2
calendar ×1
css ×1
ear ×1
el ×1
for-loop ×1
hover ×1
html ×1
java-6 ×1
java-ee ×1
java-ee-6 ×1
java-time ×1
jdk1.6 ×1
jsf ×1
jsp ×1
jstl ×1
mousehover ×1
orphan ×1
primefaces ×1
primitive ×1
python ×1
timezone ×1
war ×1
websphere ×1
wrapper ×1