spring struts 整合不了。急急急急

big_ear 2008-11-12 11:01:01
配置如下:

struts-config.xml

<action-mappings >
<action path="/test" type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="head" path="/head.jsp" />
<forward name="error" path="/error.jsp" />
</action>
</action-mappings>
<controller>
<set-property property="processorClass"
value="org.springframework.web.struts.DelegatingRequestProcessor" />
</controller>
<message-resources parameter="netstore.ApplicationResources" />
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml" />
</plug-in>


applicationContext.xml


<bean name="/test" class="action.TestAction">
</bean>

head.jsp
<form name="login" action="test.do">
<table>
<tr class="logintitle1">
<td>用户名<font color="red">*</font><input type="text" name="username"/></td>
<td><input type="submit" value="登录" onclick="return validate()"/></td>
</tr>
</form>

testAction
public class TestAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
return mapping.findForward("error");
}
...全文
145 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
big_ear 2008-11-14
  • 打赏
  • 举报
回复
呵呵,谢谢各位的关注与支持,问题解决了。
是jar包冲突了,当然也有配置多种方法引起的混乱。谢谢,结贴。
刘葛曦 2008-11-14
  • 打赏
  • 举报
回复
什么错误呀 看看
fondOfJava 2008-11-14
  • 打赏
  • 举报
回复
我测试可以啊!

<td> <input type="submit" value="登录" onclick="return validate()"/> </td>

这里换成:type = "button" 试下,

我的配置没有你复杂,


<struts-config>
<action-mappings>
<action path="/test"
type="org.springframework.web.struts.DelegatingActionProxy"
>
<forward name="error" path="/error.jsp" />

</action>
</action-mappings>

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>

</struts-config>
big_ear 2008-11-14
  • 打赏
  • 举报
回复
..............!!!!
big_ear 2008-11-13
  • 打赏
  • 举报
回复
type Status report

message /testtestAction.do

description The requested resource (/testAction.do) is not available.


web.xml 我没有更改。
Landor2004 2008-11-13
  • 打赏
  • 举报
回复
你的代码表面上没问题!
请贴出错误信息!
big_ear 2008-11-13
  • 打赏
  • 举报
回复
我不用ActionForm,只是想知道简单的整合步骤。
testAction
public class TestAction extends DispatchAction {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
return mapping.findForward("error");
}
还是不行,但我把spring撤下去,可以正常运行。
boboo_2000_0 2008-11-13
  • 打赏
  • 举报
回复
<action path="/test" type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="head" path="/head.jsp" />
<forward name="error" path="/error.jsp" />
</action>

楼主看看这里,action没有name属性,这样Struts怎么会找到ActionForm进行操作呢?
big_ear 2008-11-13
  • 打赏
  • 举报
回复
Servlet action is not available,
楼上的意思是jar包的问题吗?我引入spring,spring-mock,spring—aspects这几个jar包
海会圣贤 2008-11-13
  • 打赏
  • 举报
回复
可能是包之间的冲突吧.
big_ear 2008-11-13
  • 打赏
  • 举报
回复
异常是404错误,test.do 不可用。
sunwei_07 2008-11-13
  • 打赏
  • 举报
回复
这个网上教程实在很多,LZ把异常发出来看看

http://www.blogjava.net/oksonic/archive/2005/11/06/18370.html
linbaoer 2008-11-13
  • 打赏
  • 举报
回复
楼主貌似将几种方法都给综合了,只要选择一种方法就行了。
比如说只在struts配置文件中添加<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />
并且所有action的类保持原样应该就可以了
showde123 2008-11-13
  • 打赏
  • 举报
回复
正要学呢
Landor2004 2008-11-13
  • 打赏
  • 举报
回复
噢,上面的web.xml中不用加,如果在struts-config.xml中配置了那么就不用在web.xml中在配置了
Landor2004 2008-11-13
  • 打赏
  • 举报
回复
少包了吧,如果是spring2.5的话,应该引入包spring-webmvc-struts.jar,在spring/dist/modules中

web.xml

  <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
zidasine 2008-11-12
  • 打赏
  • 举报
回复
什么问题 异常呢
big_ear 2008-11-12
  • 打赏
  • 举报
回复
在线等待。。。。

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧