我还是个新手。我想做到的效果就是页面加载的时候就把新闻从数据库读去出来,就是一打开网页就显示出新闻的那种效果,所以想到加载的时候跳转到一个action去,
大家是怎么做的呢?

解决方案 »

  1.   

    别告诉我这个.do又返回到这个页面,
    此时if (((String) request.getSession().getAttribute("username")) == null如果成立的话,
    那岂不是一直这么前后台反反复复
      

  2.   

    不是。。现在换了个方法。。
    web.xml里的设置:
    <welcome-file-list>
        <welcome-file>findAll.do</welcome-file>
      </welcome-file-list>
    action里的跳转测试:
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    // TODO Auto-generated method stub
    request.setAttribute("msg", "跳转成功");
    return mapping.findForward("fail");
    }
    struts里的配置,是不是input的问题?:
    <action
          input="/index.jsp"
          path="/findAll"
          scope="request"
          type="com.yourcompany.struts.action.FindAllAction">
          <forward name="ok" path="/index.jsp" />
          <forward name="fail" path="/msg.jsp" />错误如下:
    type Status reportmessage /CDepartmentWeb(WebRoot的名称)/description The requested resource (/CDepartmentWeb/) is not available.
      

  3.   

    <welcome-file-list>
        <welcome-file>findAll.do </welcome-file>
      </welcome-file-list> 
    welcome-file-list不支持findAll.do这种路径映射,这里面只能是一个html、jsp等已经存在的文件你可以先谢一个jsp文件,比如index.jsp,然后
    <welcome-file-list>
        <welcome-file>index.jsp </welcome-file>
      </welcome-file-list> 
    然后再index.jsp中写转发,比如:
    <meta http-equiv="refresh" content="2; URL=<%=request.getContextPath() %>/person/queryPerson.action">
    延迟两秒后转发
    或者直接写response.sendRedirect("/xxx.do");   等
      

  4.   

    java人聚集的地方
    群号:75785340欢迎加入
      

  5.   

    这是javascript小脚本。出错为:堆栈溢出行:48页面跳转无须用函数来实现,弄个超链接就行了。
      

  6.   

    错误提示:stack overflow at line:48    错误是因为 你将数据库中的记录全部读取,并且放置在了session里面    
               我把50多万条记录 放到session里面的时候 出现了同样的错误 
    findAll.do  从该代码中看出   你应该是读取出了全部记录吧
                  是不是 可以先 top 20 条
              
                  呵呵 本人也是小雏鸟 见笑啦~-~
      

  7.   

    请 看 下我ACTION的代码,里面我还什么都没做,只是想看下这样能不能进action,说明不是以上两楼说的问题。5楼的朋友应该是对的。