初用  ssh  每次查询都用 action - service - dao  来调用,只能在地址栏里输入 xxxx。action 来调用ssh是依赖注入的,我这样写又会报空指针
        AjaxDao ajaxDao = new AjaxDao();
ajaxDao.getCruisesCompany();但是我要是 index.jsp 呢,不请求 action  怎么调用 dao 啊???注:不用 ajax谢谢~~

解决方案 »

  1.   

    先请求一个action, 比如:
    <action class="com.yeezoo.action" method="toIndex">
        <result name="success">/jsp/index</result>
    </action>
    这样请求一个action并加载数据在跳转到index.jsp就可以拉。
      

  2.   

    <action name="toIndex" class="com.yeezoo.action" method="toIndex">
        <result name="success">/jsp/index </result>
    </action> 比如:http://localhost:8080/tour/giftManage/toIndex.action
    这个giftManage是一个命名空间.
      

  3.   

    我想是地址栏输入   xxxx/xxxx/index.jsp
    就可以调用最好啊。。没有办法么。。
      

  4.   

    用jstl标签:<jsp:forward page="xxx.do"/>把这个标签写在index.jsp的body里面.然后直接访问index.jsp就可以了
      

  5.   

    <jsp:forward page="xxx.action"/> 
      

  6.   

    不请求action就在页面new 个DAO对象吧
    <%
      AjaxDao ajaxDao = new AjaxDao(); 
      ajaxDao.getCruisesCompany(); 
    %>
    然后在本页用就行了 另外 默认页是可以设置的 不一定非得是什么index.jsp
      

  7.   


    不知道写这些的朋友有没有自己试过.不会成功的!!!struts 2  使用的是 filter ,<jsp:forward 却是基于 servlet ,在这种情况下,跳转会不起作用
    如果是用 spring mvc ,或 struts1 ,是可以成功的.因为他们都是基于 servlet 可以使用 <meta http-equiv="refresh" content="0;url=index" />(推荐此种)
    或在页面建一个form ,后面跟一段 js   <script>form.submit();</script>所有的东西都通过 请求访问 ,这是安全的作法
      

  8.   

    以前我是用urlrewrite的将index.html、index.jsp等指向index.do或index.action