jsp课程设计---基于jsp的新闻发布系统内容摘要:

alert(密码不能空 )。 ()。 return false。 } } /script % String path5=(/pic/)。 % img src=%=path5 % width=200br 14 hr c:choose c:when test=${not } 用户登录: br hr form action=login method=post onsubmit=return fun(this) 账户: input type=text name=name size=15br 密码: input type=password name=pass size=16br 类别: select name=classes option selected value=general会员登录 /option option value=admin管理员登录 /option /select brbr input type=submit value=登录 input type=reset value=重置 /form br a href= target=_top会员注册 /abr ${error} /c:when c:otherwise img src=${}br font size=4 face=楷体 color=red欢迎您: font color=blue${}/font/fontbrbr a href=logout用户注销 /abr a href= target=_top添加新闻 /abr c:if test=${==39。 admin39。 } a href=page?flag=2 target=_top管理新闻 /abr /c:if /c:otherwise /c:choose /body 其中用到了 ..dbUtil 包中的 DbTool 类,其核心代码如下: public class DbTool { public static String checkLogin(GetParam gp){ Connection con=()。 PreparedStatement ps=null。 String sql=select * from userinfo where username=?。 ResultSet rs=null。 String name = (name)。 15 String pass = (pass)。 String classes = (classes)。 if((admin) amp。 amp。 !(admin)) return 没有该用户。 try{ if(con!=null){ ps=(sql)。 (1, name)。 rs=()。 if(()){ if(!(2).equals(pass)){ ()。 return 密码不正确。 }else{ return (3)。 //返回图片路径 } }else{ ()。 return 没有该用户。 } } }catch(SQLException e){ ()。 } return null。 } public static boolean add(GetParam gp,boolean isNews){ Connection con=()。 PreparedStatement ps=null。 String sql=select * from userinfo where username=?。 String sqlUser=insert into userinfo(username,pass,pic) values(?,?,?)。 String sqladd=insert into news(title,author,content,time) values(?,?,?,?)。 try { if(!isNews){ ps=(sql)。 (1, (username))。 ResultSet rs=()。 if(()){ return false。 } 16 String name[]={username,pass,pic}。 ps=(sqlUser)。 for(int i=0。 i。 ++i) for(int j=0。 j()。 ++j){ if(name[i].equals((j))){ (i+1,(name[i]))。 } } ()。 ()。 return true。 }else{ ps=(sqladd)。 String name[]={title,author,content,time}。 for(int i=0。 i。 ++i) for(int j=0。 j()。 ++j){ if(name[i].equals((j))){ (i+1,(name[i]))。 } } ()。 ()。 } } catch (SQLException e) { ()。 } return false。 } public static void update(GetParam gp, String id){ Connection con=()。 PreparedStatement ps=null。 String sqlupdate=update news set title=?,author=?,content=?,time=? where id = ?。 try { ps=(sqlupdate)。 } catch (SQLException e1) { ()。 } String name[]={title,author,content,time}。 for(int i=0。 i。 ++i){ for(int j=0。 j()。 ++j){ if(name[i].equals((j))){ 17 try { (i+1,(name[i]))。 } catch (SQLException e) { ()。 } } } } try { (5, id)。 ()。 ()。 } catch (SQLException e) { ()。 } } public static ArrayListNewVO getRow(){ ArrayListNewVO list=new ArrayListNewVO()。 Connection con=()。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。