首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

各位老大,struts的一个小疑点,但是折磨小弟我三天了,请大家帮忙

2012-01-22 
各位老大,struts的一个小问题,但是折磨我三天了,请大家帮忙!刚入职,要编一个增删查改的功能的页面,用STRUT

各位老大,struts的一个小问题,但是折磨我三天了,请大家帮忙!
刚入职,要编一个增删查改的功能的页面,用STRUTS。下面是我的STRUTS-CONFIG。
<?xml   version= "1.0 "   encoding= "UTF-8 "?>
<!DOCTYPE   struts-config   PUBLIC   "-//Apache   Software   Foundation//DTD   Struts   Configuration   1.1//EN "   "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd ">

<struts-config>
    <data-sources   />
    <form-beans>
    <form-bean   type= "com.dhc.dota.DotaVo "   name= "DotaVoForm "   />
    </form-beans>
    <global-exceptions   />
    <global-forwards   />
   
    <action-mappings>
    <action   path= "/DotaCreate "   type= "com.dhc.dota.action.DotaCreateAction "   name= "DotaVoForm "   parameter= "method "   input= " "   scope= "session ">
            <forward   path= "/Sucess.jsp "   name= "sucesspage "/>
            <forward   path= "/Fail.jsp "   name= "fail "/>
            <forward   path= "/DotaCreate.jsp "   name= "newpage "/>
        </action>
      <action   path= "/DotaLista "   type= "com.dhc.dota.action.DotaListAction "       name= "DotaVoForm "   parameter= "method "   scope= "session ">
              <forward   path= "/index.jsp "   name= "listpage ">
        </forward>
        </action>
          <action   path= "/DotaDel "   type= "com.dhc.dota.action.DotaDelAction "   name= "DotaVoForm "   parameter= "method "   scope= "session ">
              <forward   path= "/Sucess.jsp "   name= "sucesspage "/>
        <forward   path= "/Fail.jsp "   name= "fail "   redirect= "false "/>

        </action>
          <action   path= "/DotaUpd "   type= "com.dhc.dota.action.DotaUpdateAction "   name= "DotaVoForm "   parameter= "method "   scope= "session ">
              <forward   path= "/DotaUpdate.jsp "   name= "updatepage "/>
              <forward   path= "/Sucess "   name= "sucesspage "/>
              <forward   path= "/Fail.jsp "   name= "fail "/>
          </action>
          <action   path= "/DotaDetail "   type= "com.dhc.dota.action.DotaDetailAction "   name= "DotaVoForm "   parameter= "method "   scope= "session ">
              <forward   path= "/DotaDetail.jsp "   name= "detailpage "/>


                <forward   path= "/Sucess "   name= "sucesspage "/>
              <forward   path= "/Fail.jsp "   name= "fail "/>
     
        </action>
    </action-mappings>
    <message-resources   parameter= "com.dhc.dota.ApplicationResources "   />
</struts-config>


在com.dhc.dota.action.DotaListAction中有一个方法,将数据库中的信息存到一个LIST中,下面是代码:

public   class   DotaListAction   extends   Action{
public   ActionForward   listall(ActionMapping   mapping,   ActionForm   form,   HttpServletRequest   request,   HttpServletResponse   response)   throws   Exception   {
DotaIml   iml=new   DotaIml();
List   list   =   iml.getlist();
System.out.print( "asdfghhj ");
request.setAttribute( "DotaList ",   list);
return   mapping.findForward( "listpage ");
}

}
最后是JSP页面index.jsp,代码如下:


<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   import= "java.util.* "   errorPage= " "   %>
<%@   taglib   uri= "/WEB-INF/struts-html.tld "   prefix= "html "%>
<%@   taglib   uri= "/WEB-INF/struts-bean.tld "   prefix= "bean "%>
<%@   taglib   uri= "/WEB-INF/struts-logic.tld "   prefix= "logic "%>
<%@   taglib   uri= "/WEB-INF/struts-nested.tld "   prefix= "nested "%>
<%@   taglib   uri= "/WEB-INF/struts-tiles.tld "   prefix= "tiles "%>
<%@taglib   uri= "WEB-INF/c.tld "   prefix= "c "%>


<%
String   path   =   request.getContextPath();
String   basePath   =   request.getScheme()+ ":// "+request.getServerName()+ ": "+request.getServerPort()+path+ "/ ";
%>




<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html>
    <head>
        <base   href= " <%=basePath%> ">
       
        <title> My   JSP   'index.jsp '   starting   page </title>
       
        <meta   http-equiv= "pragma "   content= "no-cache ">
        <meta   http-equiv= "cache-control "   content= "no-cache ">
        <meta   http-equiv= "expires "   content= "0 ">
        <meta   http-equiv= "keywords "   content= "keyword1,keyword2,keyword3 ">
        <meta   http-equiv= "description "   content= "This   is   my   page ">
       
       
        <link   rel= "stylesheet "   type= "text/css "   href= "styles.css ">


       
    </head>
   
    <body>
    <br>
    <form   name= "form1 "   method= "post "   action= " ">
        <table   align= "center "   bgcolor= "#008888 "   border= "1 "   cellspacing= "2 "   cellpadding= "4 ">
        <tr   bgcolor= "#ccccc ">
        <td> <b> 姓名 </b> </td>
        <td> <b> 性别 </b> </td>
        <td> <b> 年龄 </b> </td>
        <td> <b> 查看 </b> </td>
        <td> <b> 修改 </b> </td>
        <td> <b> 删除 </b> </td>  
       
          <logic:present   name= "Dotalist ">
         
          <logic:iterate   id= "lio "   name= "Dotalist ">
          <td> <bean:write   name= "lio "   property= "name "/> </td>
               
          <td> <bean:write   name= "lio "   property= "sex "/> </td>
          <td> <bean:write   name= "lio "   property= "age "/> </td>
          <td> <html:link   page= "/DotaDetaillAction.do "   paramId= "id "   paramName= "id "   paramProperty= "id "> 查看具体信息 </html:link> </td>
          <td> <html:link   page= "/DotaUpdateAction.do "   paramId= "id "   paramName= "id "   paramProperty= "id "> 修改具体信息 </html:link> </td>
        <td> <html:link   page= "/DotaDelAction.do "   paramId= "id "   paramName= "id "   paramProperty= "id "> 删除 </html:link> </td>
        </tr>
        </logic:iterate>
        </logic:present>
        </table>
        <a   href= "DotaCreate.do?method=forwardCreate "> <b> <bean:message   key= "dota.new "   /> </b> </a>
    </form>
   
    </body>
</html>
我通过在浏览器中输入:http://localhost:8080/webtest/DotaLista.do?method=listall为什么显示的是一个空白页面的,我保证文件的存放格式都是正确的。谢谢大家,想了三天了!在线等。

[解决办法]
你先在action里看看能不能取到list,如果取到了,你就把精力放到页面上,一般的空白页都是页面的问题,如果后台报错,就太好了,在后台解决就可以了

[解决办法]
up

热点排行