<select name="channelList" id="channel_${sta.index}" onchange="getChannelCode(this)" style="width:130font-size:11px" ${allot.channel==null?'':'disabled' }>
<option value="${allot.brand.brd_code}">${allot.channel.com_desc}</option>
<s:if test="#allot.brand!=null">
<s:if test="#allot.channel==null">
<s:iterator value="allChannel">
<option value="${com_code }">${com_desc }</option>
</s:iterator>
</s:if>
</s:if>
</select>
DAO 的select://自己对照去改参数!我查询的表里面有4个字段!public static String login(String id,String word){
Connection conn = null
Statement stmt = null
ResultSet rs = null
String power=""
try{
conn = min.getConnection()
stmt = conn.createStatement()
rs = stmt.executeQuery( "SELECT * FROM roudian WHERE userid='"+id+"' AND password='"+word+"'")
while(rs.next()){
power=rs.getString(4)
}
}catch(Exception e){
e.printStackTrace()
}finally{
min.closeConnection(conn)
}
return power
}
Action:
if(request.getParameter("method").equals("login")){
String id = request.getParameter("id")
String word = request.getParameter("word")
String power=DeptDao.login(id,word)
if(power.equals("1")||power.equals("2")){
forword="adminframe"
session.setAttribute("power",power)
}else{
message="用户名或密码错误!"
forword="select"
}
}
if(request.getParameter("method").equals("power")){
String power=session.getAttribute("power").toString()
if(power.equals("1")){
forword="dept"
session.setAttribute("power",power)
}else{
message = "失败"
forword="select"
}
}
先写的DAO:public List<FileModel>findAll(){
Connection con = null
PreparedStatement ps = null
FileModel file = null
ResultSet rs = null
List<FileModel>set = null
try
{
con = DBconnection.getConnection()
String sql = "select * from file
ps = con.prepareStatement(sql)
set = new LinkedList<FileModel>()
rs = ps.executeQuery()
while(rs.next())
{
file = new FileModel()
file.setFilepath(rs.getString(1))
file.setFiletime(rs.getTimestamp(2))
file.setFileintroduce(rs.getString(3))
file.setFilediscuss(rs.getString(4))
file.setFilescore(rs.getFloat(5))
file.setFiletype(rs.getString(6))
file.setDirection(rs.getString(7))
file.setFileid(rs.getInt(8))
file.setFilename(rs.getString(9))
set.add(file)
}
}
catch(SQLException e)
{
throw new RuntimeException(e.getMessage(),e)
}
finally
{
DBconnection.free(rs, ps, con)
}
return set
}
在action中调用DAO:
public class FindAction extends ActionSupport {
private Dao dao = new Dao()
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
LinkedList<FileModel>modelSet = (LinkedList<FileModel>) dao.findAll()
if (modelSet!=null){
System.out.println(modelSet)
ActionContext.getContext().getSession().put("msg", modelSet)
return SUCCESS}
else
return ERROR
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)