de
public String execute() throws Exception {
// TODO Auto-generated method stub
Connection conn=DBUtil.getConnection();
ResultSet rs = DBUtil.getResultSet("select * from user where username = '"+ user.getUsername()+ "'and grade='0'", conn);
if(rs.next())
{
if(rs.getString(2).equals(user.getPassword()))
{
HttpServletRequest request=ServletActionContext.getRequest();
String name="name";
String password="password";
HttpSession session=request.getSession();
session.setAttribute(name, user.getUsername());
session.setAttribute(password, user.getPassword());
DBUtil.close(conn);
return SUCCESS;
}
else
{
fe.setLoginerror("管理员密码错误,请重新输入!");
DBUtil.close(conn);
return INPUT;
}
}
else
{
fe.setLoginerror("管理员不存在!");
DBUtil.close(conn);
return "INPUT1";
}
}
}
//发布话题action
package com.action;
import java.sql.Connection;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.omg.CORBA.Request;
import com.opensymphony.xwork2.ActionSupport;
import com.bean.*;
public class AnnounceAction extends ActionSupport {
private Topic topic=new Topic();
public Topic getTopic() {
return topic;
}
public void setTopic(Topic topic) {
this.topic = topic;
}
public String execute() throws Exception {
// TODO Auto-generated method stub
int i=0;
Connection conn=DBUtil.getConnection();
String sql="insert into topic(title,content,author,submittime,forumid)values('"+topic.getTitle()+"','"+topic.getContent()+"','"+topic.getAuthor() +"'
," +"'"+ new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())+"','"+topic.getForumid()+"')";
i=DBUtil.excuteSql(sql, conn);
DBUtil.close(conn);
if(i>0)
{
return SUCCESS;
}else
return INPUT;
}
}
//回复action
package com.action;
import java.sql.Connection;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.servlet.http.HttpServletRequest;
import com.bean.Topic;
import com.bean.TopicRes;
import com.opensymphony.xwork2.ActionSupport;
public class AnnounceResponseAction extends ActionSupport {
private TopicRes topicre=new TopicRes();
private Topic topic =new Topic();
public TopicRes getTopicre() {
return topicre;
}
public void setTopicre(TopicRes topicre) {
this.topicre = topi
cre;
}
public Topic getTopic() {
return topic;
}
public void setTopic(Topic topic) {
this.topic = topic;
}
public String execute() throws Exception {
// TODO Auto-generated method stub
Connection conn=DBUtil.getConnection();
String titletemp=topic.getTitle();
int tempid=topicre.getId();
try{ResultSet rs=DBUtil.getResultSet("select title from topic where id='"+topicre.getId()+"'", conn);
if(rs.next())