频繁操作后tomcat 页面没反应,但日志没显示错误或关闭,出没输出任何错误,框架是用struts1.2,
部分代码如下
//action
public ActionForward comment(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
URLform uform=(URLform)form;
Connection conn = null;
try{
conn=getDataSource(request,"sqlServer").getConnection();
commentBean cbean=new commentBean();
cbean.setConn(conn);
//记录用户的操作
actionBean action = new actionBean();
action.setConn(conn);
action.setAction("评论");
action.setUrl("");
action.setUserID((String)request.getSession().getAttribute("userid"));
if(request.getParameter("id")!=null){
uform.setUrlID(request.getParameter("id"));
return mapping.findForward("comment");
}else{
cbean.setComment(Chinese.convert(uform.getComment()));
System.out.println(Chinese.convert(uform.getComment()));
cbean.setUrlID(uform.getUrlID());
cbean.setUserID((String)request.getSession().getAttribute("userid"));
String userid=(String)request.getSession().getAttribute("userid");
if(cbean.addComment()==1){
action.inputRecord();
if(userid!=null){
response.sendRedirect("userClass.do");
}else response.sendRedirect("admin.jsp");
}else{
response.sendRedirect("fail.jsp");
}
}
}catch(SQLException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
return null;
}
//bean
public int addComment(){
String sql="insert into comment(comment,userID,urlID) values('"
+comment+"','"
+userID+"','"
+urlID
+"')";
try{
Statement stmt = conn.createStatement();
int line = stmt.executeUpdate(sql);
return line;
}catch(SQLException e){
e.printStackTrace();
}
return -1;
}
struts-config.xml
<action
attribute="URLForm"
input="/comment.jsp"
name="URLForm"
path="/comment"
scope="request"
type="action.userAction"
parameter="comment">
<forward name="comment" path="/comment.jsp" />
</action>其它的代码均有些相似,我想知道是什么引起,或者在哪里造成死循环,求高手帮忙!
部分代码如下
//action
public ActionForward comment(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
URLform uform=(URLform)form;
Connection conn = null;
try{
conn=getDataSource(request,"sqlServer").getConnection();
commentBean cbean=new commentBean();
cbean.setConn(conn);
//记录用户的操作
actionBean action = new actionBean();
action.setConn(conn);
action.setAction("评论");
action.setUrl("");
action.setUserID((String)request.getSession().getAttribute("userid"));
if(request.getParameter("id")!=null){
uform.setUrlID(request.getParameter("id"));
return mapping.findForward("comment");
}else{
cbean.setComment(Chinese.convert(uform.getComment()));
System.out.println(Chinese.convert(uform.getComment()));
cbean.setUrlID(uform.getUrlID());
cbean.setUserID((String)request.getSession().getAttribute("userid"));
String userid=(String)request.getSession().getAttribute("userid");
if(cbean.addComment()==1){
action.inputRecord();
if(userid!=null){
response.sendRedirect("userClass.do");
}else response.sendRedirect("admin.jsp");
}else{
response.sendRedirect("fail.jsp");
}
}
}catch(SQLException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
return null;
}
//bean
public int addComment(){
String sql="insert into comment(comment,userID,urlID) values('"
+comment+"','"
+userID+"','"
+urlID
+"')";
try{
Statement stmt = conn.createStatement();
int line = stmt.executeUpdate(sql);
return line;
}catch(SQLException e){
e.printStackTrace();
}
return -1;
}
struts-config.xml
<action
attribute="URLForm"
input="/comment.jsp"
name="URLForm"
path="/comment"
scope="request"
type="action.userAction"
parameter="comment">
<forward name="comment" path="/comment.jsp" />
</action>其它的代码均有些相似,我想知道是什么引起,或者在哪里造成死循环,求高手帮忙!
解决方案 »
- 新手求教这一句哪里错了?
- struts2的select标签
- 在线解决马上发分 tamcat设置
- jsp配置问题
- 在Eclipse BS网站可以在后台调用exe,部署到网站后 就无法调用exe
- 新手学习spring,struts,security整合项目实例神器,顺便散分...
- 一个jsp页面出现'Response has already been committed, be sure not to write to the OutputStream '问题
- 连接池中一个connection最佳的使用次数是多少啊?
- hibernate反向工程怎么自动实现List接口
- 新人一枚,求代码!如何用Java将数据库里的两个相同结构表的数据进行比较?
- 求高手求出下面的sql语句
- 打印pdf文件 在tomcat下正常 部署到jboss下就出问题?
<set-property property="minCount" value="20"/>
<set-property property="maxCount" value="50"/>
在每次使用数据库连接后,都有
finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}关闭连接数据库