代码给全点啊,只写一句哪知道你是怎么调用的title呀。起码也得把form给出来呀

解决方案 »

  1.   

    我没有用title是这样的在ActionFormBean中有一个超链接的标签< a href ='...'>...</a>然后返回到jsp页面
    就是这样一个过程!
      

  2.   

    actionFormBeanpackage question;import org.apache.struts.action.*;
    import javax.servlet.http.*;
    import javax.sql.DataSource;
    import java.sql.*;
    import javax.servlet.ServletContext;
    import java.util.*;
    import javax.naming.*;public class indexAction
        extends Action {
        public ActionForward execute(ActionMapping actionMapping,
                                     ActionForm actionForm,
                                     HttpServletRequest httpServletRequest,
                                     HttpServletResponse httpServletResponse) {        DataSource dataSource = null;
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
            String sql = null;
            ArrayList table = null;
            indexActionForm row = null;
            //分页变量
            String url = "indexAction.do";
            String queryString = "";
            int page = 0;
            int pageSize = 5;
            String batchShowUrl = "";
            int tmpi = 0;        String title = "";
            int id;        sql = "select * from question";
            DB db = new DB();
            db.getConnect();
            //rs = db.query(sql);
            try {
                page = Integer.parseInt(httpServletRequest.getParameter("page"));
            }
            catch(NumberFormatException e){
                page = 1;
            }
            rs = db.batchShow(sql, pageSize, page, url, queryString);
            batchShowUrl = db.getBatchShowUrl();        table = new ArrayList();
            try {
                while (!rs.isAfterLast() && tmpi < pageSize) {
                    tmpi++;
                    row = new indexActionForm();
                    //row.setTitle(rs.getString("title"));
                    title = rs.getString("title");
                    id = rs.getInt("id");
                    title = new String(title.getBytes("ISO8859-1"));
                    title = "<a href='view.do?id=" + id + "' target='_blank'>" + title + "</a>";
                    row.setTitle(title);
                    row.setNickname(rs.getString("nickname"));
                    row.setAddtime(rs.getString("addtime"));
                    rs.next();
                    table.add(row);
                }
            }
            catch (Exception e) {
                System.out.println("rs.next error:" + e);
            }
            finally {
                try {
                    rs.close();
                    db.close();
                }
                catch (Exception e) {}
            }
            httpServletRequest.setAttribute("batchShowUrl", batchShowUrl);
            httpServletRequest.setAttribute("table", table);
            return actionMapping.findForward("index");
        }
    }
      

  3.   

    jsp<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ page contentType="text/html; charset=GBK" %>
    <html>
    <head>
    <title>首页</title>
    </head>
    <body bgcolor="#c0c0c0">
    <div align="center" style="font-size:16pt"> <b>Struts数据库入门实例--简单答疑系统</b></div>
    <div align="center"><html:form action="/indexAction">
      <table border="0" cellpadding="1" cellspacing="1" bgcolor="#000000" align="center" width="600">
        <tr bgcolor="#CCCCCC">
          <td colspan="3" align="right"><%=request.getAttribute("batchShowUrl")%></td>
        </tr>
        </tr>
          <tr bgcolor="#CCCCCC">
          <td width="358" align="center"><b>Question</b></td>
          <td width="97"><b>Nickname</b></td>
          <td align="center" width="135"><b>Addtime</b></td>
        </tr>
        <!--列出数据-->
        <logic:notEmpty name="table">
        <logic:iterate id="row" name="table" scope="request">
        <tr bgcolor="#CCCCCC">
          <td width="358"><bean:write name="row" property="title"/></td>
          <td width="97"><bean:write name="row" property="nickname"/></td>
          <td align="center" width="135"><bean:write name="row" property="addtime"/></td>
        </tr>
        </logic:iterate>
        </logic:notEmpty>
        <tr bgcolor="#CCCCCC">
          <td colspan="3" align="right"><%=request.getAttribute("batchShowUrl")%></td>
        </tr>
      </table>
      <html:link href="addQuestion.jsp" >Add Question</html:link> </html:form> </div>
    </body>
    </html>
      

  4.   

    http://www.javayou.com/showlog.jspe?log_id=166#836
      

  5.   

    <%@ page contentType="text/html; charset=GBK" %>
    改为
    <%@ page contentType="text/html; charset=gb2312" %>
    试试吧,有时struts会把代码变成二进制的代码,我也部太清楚