S2SH无配置详解
2014-02-13 09:39
197 查看
1. hibernate
hebernate3.0后可以使用注解自动映射删除配置文件,加入的包是hibernate-annotations-3.3.1.GA.jar和ejb3-persistence-1.0.1.GA.jar就可以实现(版本可以不同)。
例子:
@Entity
@Table(name="airline")
publicclass AirLine
implements Serializable{
private String
alid;
private Office
ofid;
private String
name;
private String
netaddress;
private String
code;
private String
moneyphone;
private String
ticketphone;
private Integer
impower;
private Integer
type ;
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid",strategy="uuid.hex")
public String getAlid() {
returnalid;
}
publicvoid setAlid(String alid) {
this.alid = alid;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="ofid")
public Office getOfid() {
returnofid;
}
publicvoid setOfid(Office ofid) {
this.ofid = ofid;
}
public String getName() {
returnname;
}
publicvoid setName(String name) {
this.name = name;
}
public String getNetaddress() {
returnnetaddress;
}
publicvoid setNetaddress(String netaddress) {
this.netaddress = netaddress;
}
public String getCode() {
returncode;
}
publicvoid setCode(String code) {
this.code = code;
}
public String getMoneyphone() {
returnmoneyphone;
}
publicvoid setMoneyphone(String moneyphone) {
this.moneyphone = moneyphone;
}
public String getTicketphone() {
returnticketphone;
}
publicvoid setTicketphone(String ticketphone) {
this.ticketphone = ticketphone;
}
public Integer getImpower() {
returnimpower;
}
publicvoid setImpower(Integer impower) {
this.impower = impower;
}
public Integer getType() {
returntype;
}
publicvoid setType(Integer type) {
this.type = type;
}
}
只有主键和关联外键有注释其他都可以没有注释。
2. struts2
struts2.1后可以使用“约定大约”插件实现0配置文件,规则是返回值为jsp的一部分名称jsp的全名为“类名”-“返回值”中间横杠隔开---convention_plugin.jar。
例子:
publicclass HelloWordAction{
publicString list(){
return“list”;
}
}
对应的jsp页面是:hello-word-list.jsp类名要小写多个单词的用横岗隔开返回值在最后。
3. spring
spring2.1以后set()、get()方法注入可以自动注入不用写set()、get()方法。
例子:
@Autowired
private FeatureManager
featureManager;
不用再写出featureManager的set()、get()方法了,在applicationContext.xml中这样配置:
<!--
使用annotation
自动注册bean,并保证@Required,@Autowired的属性被注入 -->
<context:component-scan
base-package="org.eline.dao,org.eline.service"
/>
放在最外层的<beans>下
<bean
id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
……之前不变在最后加入
<!--
自动注入实体bean -->
<property
name="packagesToScan"
value="org.eline.entity*.*"
/>
</bean>
就可以使用了
4,struts2配置action的入口
hebernate3.0后可以使用注解自动映射删除配置文件,加入的包是hibernate-annotations-3.3.1.GA.jar和ejb3-persistence-1.0.1.GA.jar就可以实现(版本可以不同)。
例子:
@Entity
@Table(name="airline")
publicclass AirLine
implements Serializable{
private String
alid;
private Office
ofid;
private String
name;
private String
netaddress;
private String
code;
private String
moneyphone;
private String
ticketphone;
private Integer
impower;
private Integer
type ;
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid",strategy="uuid.hex")
public String getAlid() {
returnalid;
}
publicvoid setAlid(String alid) {
this.alid = alid;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="ofid")
public Office getOfid() {
returnofid;
}
publicvoid setOfid(Office ofid) {
this.ofid = ofid;
}
public String getName() {
returnname;
}
publicvoid setName(String name) {
this.name = name;
}
public String getNetaddress() {
returnnetaddress;
}
publicvoid setNetaddress(String netaddress) {
this.netaddress = netaddress;
}
public String getCode() {
returncode;
}
publicvoid setCode(String code) {
this.code = code;
}
public String getMoneyphone() {
returnmoneyphone;
}
publicvoid setMoneyphone(String moneyphone) {
this.moneyphone = moneyphone;
}
public String getTicketphone() {
returnticketphone;
}
publicvoid setTicketphone(String ticketphone) {
this.ticketphone = ticketphone;
}
public Integer getImpower() {
returnimpower;
}
publicvoid setImpower(Integer impower) {
this.impower = impower;
}
public Integer getType() {
returntype;
}
publicvoid setType(Integer type) {
this.type = type;
}
}
只有主键和关联外键有注释其他都可以没有注释。
2. struts2
struts2.1后可以使用“约定大约”插件实现0配置文件,规则是返回值为jsp的一部分名称jsp的全名为“类名”-“返回值”中间横杠隔开---convention_plugin.jar。
例子:
publicclass HelloWordAction{
publicString list(){
return“list”;
}
}
对应的jsp页面是:hello-word-list.jsp类名要小写多个单词的用横岗隔开返回值在最后。
3. spring
spring2.1以后set()、get()方法注入可以自动注入不用写set()、get()方法。
例子:
@Autowired
private FeatureManager
featureManager;
不用再写出featureManager的set()、get()方法了,在applicationContext.xml中这样配置:
<!--
使用annotation
自动注册bean,并保证@Required,@Autowired的属性被注入 -->
<context:component-scan
base-package="org.eline.dao,org.eline.service"
/>
放在最外层的<beans>下
<bean
id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
……之前不变在最后加入
<!--
自动注入实体bean -->
<property
name="packagesToScan"
value="org.eline.entity*.*"
/>
</bean>
就可以使用了
4,struts2配置action的入口
相关文章推荐
- S2SH配置过程 详解(1)
- S2SH配置过程 详解(2)
- S2SH配置过程 详解(3)
- S2SH配置过程 详解(4)
- 全新S2SH配置一步一步过程详解 转载请注明
- S2SH配置过程 详解(5)
- s2sh的配置详解
- 全新S2SH配置一步一步过程详解
- Linux下Squid配置详解 Squid代理服务器配置第1/3页
- MySQL my.ini 配置文件详解
- Hibernate 主配置文件详解
- CentOS---网络配置详解
- centos下fail2ban安装与配置详解_Linux
- nginx服务器中access_log日志分析与配置详解
- DWR配置文件详解
- Redis配置详解
- (转)sshd_config配置 详解
- Nginx 目录配置详解
- Android GreenDao3.2配置及使用详解
- Linux 下Redis安装与集群配置 Redis配置文件详解