在我的网站上,我想在具有特定大小(width: 600px)的新窗口中显示用户上传的图像.问题是图像可能很大.因此,如果它们比这些更大600px,我想调整它们的大小,保留纵横比.
我尝试了max-widthCSS属性,但它不起作用:图像的大小不会改变.
有什么方法可以解决这个问题吗?
HTML:
<div id="ImageContainerr">
<img src="DisplayImage.do?ad_id=${requestScope.advert.id}" class="Image" />
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
img.Image { max-width: 100%;}
div#ImageContainer { width: 600px; }
Run Code Online (Sandbox Code Playgroud)
我也试过设置max-width: 600px图像,但不起作用.图像从servlet流式传输(存储在Tomcat的webapps文件夹之外).
我正在使用JBoss AS 7.1.1,我的数据库出现问题 - 每次重启服务器时都会被删除.您可以在下面看到我的持久性文件的内容:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="wyklad2">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)
DataSource配置:
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
Run Code Online (Sandbox Code Playgroud)
我将非常感谢能够帮助我解决这个问题的任何线索.
假设我有两个实体:
@Entity
public class Customer implements Serializable {
...
@OneToMany(cascade=ALL, mappedBy="customer")
public Set<Order> getOrders() {
return orders;
}
...
}
@Entity
public class Order implements Serializable {
...
@ManyToOne
@JoinColumn(name="CUST_ID", nullable=false)
public Customer getCustomer() {
return customer;
}
...
}
Run Code Online (Sandbox Code Playgroud)
然后,我是持久的Customer实体,之后,Order实体参考之前添加的Customer.当我从数据库中检索此客户并调用getOrders时,它返回空集.这是正常的行为吗?如果是,我在添加新订单实体时如何自动刷新此设置?