直接在地址栏中输入index.jsp,页面直接显示从数据库取出来的新闻
也就是说没有按钮或者链接来写action
怎么做??

解决方案 »

  1.   

    在index.jsp页面中使用
    <jsp:forward path=" "/>来链接action
      

  2.   

    是这样吗?
    <jsp: forward page="/level.do?title=selectall"/>
      

  3.   

    你可以在页面中使用隐藏域的方式来实现这个功能。例如<html:form action="/login" method="post">
    <input type="hidden" name="action" value="seleceAllMessage"/>
    </html:form>
    说明一下:action中所填写的值是在struts的配置文件中配置的。是strtus-config.xml中的path="/login"。name引用的是在struts-config.xml配置文件中给定的初始化参数的值:parameter="action" 。至于value的值就是在action中要具体写的方法。当然这里面要使用动态action。
      

  4.   

    把index.jsp变为跳转页面,
    %@ page language="java" import="java.util.*" pageEncoding="gbk"%>
    <html>
    <head>
    <title>正在进入系统...</title>
    <script type="text/javascript">
    function showMain()
    {
    document.form1.submit();
    }
    </script>
    </head>

    <body onload="showMain()">
    <form name="form1" action="showMain.action?libraryID=1&versionId=1" method="get">

    </form>

    正在进入系统...
    </body>
    </html>