Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区 » J2EE SDK  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 struts不能跳转?
dafeng520





发贴: 6
积分: 0
于 2007-04-03 15:07 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在eclipse下建了一个简单的工程测试struts,不通,写了两个JSP用于跳转的,jsp中没有用到任何数据只有一个链接:
<body>
<a href="<%=basePath%>test.do">往后跳转</a>
</body>

struts-config.xml 里:
<struts-config>
<data-sources />
<form-beans />
<global-exceptions />
<global-forwards />
<action-mappings >
  <action path="/test" type="test.action.TestAction"
      scope="request"
      validate="false">
      <forward name="ok" path="/end.jsp" />
  </action>
</action-mappings>
<message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>

action类:
public class TestAction extends Action {
  public ActionForward execute(ActionMapping mapping,HttpServletRequest request){
    return mapping.findForward("ok");
  }
}

请问连这么简单的跳转 都跳不过去,地址对,页面空白,没有要显示的,也不报任何错误,没有日志,不知是何原因?初学者,请各位大侠指正!!用tomcat 服务器



作者 Re:struts不能跳转? [Re:dafeng520]
420124830729311





发贴: 1
积分: 0
于 2007-04-03 20:26 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
是不是.do 触发struts Serv let 呢,
你的配置文件有问题吗,检查在看看



作者 Re:struts不能跳转? [Re:dafeng520]
dafeng520





发贴: 6
积分: 0
于 2007-04-04 09:09 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的web.xml是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>

这个不应该有错吧?



作者 解决了 [Re:dafeng520]
dafeng520





发贴: 6
积分: 0
于 2007-04-04 09:41 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
方法少两个参数:
public ActionForward execute(ActionMapping mapping,HttpServletRequest request)

应该是:
public ActionForward execute(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)

请大家务必小心,别范我这种低级错误




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923