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"
}
}
先在action里定义一个集合并通过业务程的方法取得数据,如我下面的channelList;在页面需通过select的name=""来获得action中定义的集合,再在option里指定value,value为集合的属性:<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>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)