阅读教程

struts面试 考题

[日期:2008-07-13] 来源:  作者:志伟

在面试时,大多会问到:STRUTS运行流程比较重要, 熟悉几个配置文件,如何实现对FORM的验证什么的

 

下面是一道有关Struts面试题


题目:
现有两张表,一张为新闻类别表


有2个字段:

nid(pk) sort


另外一张新闻内容表
有三个字段

cid(pk) nid(fk) title content

要求通过下拉列表框的方法选择新闻类别然后显示该类别的新闻标题(在当前页中显示)
我是用Struts2+Hibernate3.2+JPA实现的.
数据库脚本:

create database if not exists news;
drop table if exists newssort;
create table newssort
(
 nid int primary key AUTO_INCREMENT
 sort varchar(50)
);

drop table if exists news;
create table news
(
 cid int primary key AUTO_INCREMENT
 title varchar(50) not null
 content varchar(500) not null
 nid int null
);

insert into newssort values(null'娱乐');
insert into newssort values(null'时事');

insert into news values(null'好事''好事连连哈哈'1);
insert into news values(null'坏事''坏事不断'1);
insert into news values(null'爱情是什么''爱情是什么啊还没知道呢'2);
insert into news values(null'什么啊''测试内容'2);

select * from news;
select * from newssort;

两个VO类:
News.java:

package com.vo;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@SuppressWarnings("serial")
@Entity
@Table(name="news")
public class News implements Serializable
{
 private Integer cid;
 private String title;
 private String content;
 @Id
 @GeneratedValue(strategy=GenerationType.AUTO)
 public Integer getCid()
 {
 return cid;
 }

 public void setCid(Integer cid)
 {
 this.cid = cid;
 }

 public String getTitle()
 {
 return title;
 }

 public void setTitle(String title)
 {
 this.title = title;
 }

 public String getContent()
 {
 return content;
 }

 public void setContent(String content)
 {
 this.content = content;
 }
}

Newssort.java:

package com.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

@SuppressWarnings("serial")
@Entity
@Table(name = "newssort")
public class Newssort implements Serializable
{
 private Integer nid;
 private String sort;
 private List news = new ArrayList();
 @OneToMany
 @JoinColumn(name="nid")
 @LazyCollection(LazyCollectionOption.FALSE)
 public List getNews()
 {
 return news;
 }

 public void setNews(List news)
 {
 this.news = news;
 }

 @Id
 @GeneratedValue(strategy = GenerationType.AUTO)
 public Integer getNid()
 {
 return nid;
 }

 public void setNid(Integer nid)
 {
 this.nid = nid;
 }
 
 public String getSort()
 {
 return sort;
 }

 public void setSort(String sort)
 {
 this.sort = sort;
 }
}



      
      使用百度搜索:struts面试 考题百度中搜索:struts面试 考题
阅读:
录入:志伟

评论 】 【 推荐 】 【 打印
上一篇:
下一篇:
相关教程      
本文评论       全部评论
  问题太肤浅了   (路过 ,2008-09-13 )
发表评论


点评: 字数
姓名:

 
搜一下


 
本周热门教程
 

关于我们 | 广告合作 | 法律声明 | 联系站长 | 网站地图 | 网站搜索 | | Top ↑
Copyright © 志伟教程资料网 Powered by zhiweinet 1.0
 本栏目提供:struts面试 考题