springside的问题一般没人回答吗?

liuyyuns 2010-05-06 02:28:48
我的TeacherAction类在service包下面,这样我在struts.xml里面怎么配置我自己的action呢?有知道的吗?问题不解决就进行不下去。给我贴一段代码也行。
...全文
130 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
xinlan1022 2010-05-07
  • 打赏
  • 举报
回复
都用 springside了,怎么不用annotation
liuyyuns 2010-05-07
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 liuyyuns 的回复:]
这个问题我已经解决了,还是在struts.xml里面配置一个action。action的代码如下:

XML code

<action name="student1" class="com.action.StudentAction">
<result>student1.jsp</result>
</action>


这样能成功的原因是我……
[/Quote]
这样写就可以,但是下面的写法就不行,我尽量的用代码说话,因为我的表达不是太清楚。

<action name="student1" class="com.action.StudentAction">
<result name="success">/content/study/student1.jsp</result>
</action>
liuyyuns 2010-05-07
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 liuyyuns 的回复:]
这个问题我已经解决了,还是在struts.xml里面配置一个action。action的代码如下:

XML code

<action name="student1" class="com.action.StudentAction">
<result>student1.jsp</result>
</action>


这样能成功的原因是我……
[/Quote]
问题的原因是student1.jsp在WebRoot下直接建的可以访问到,但是在webRoot下的content/study下面新建就访问不到,这个又是什么原因呢,还是由于权限的问题?
liuyyuns 2010-05-06
  • 打赏
  • 举报
回复
这个问题我已经解决了,还是在struts.xml里面配置一个action。action的代码如下:

<action name="student1" class="com.action.StudentAction">
<result>student1.jsp</result>
</action>

这样能成功的原因是我的com.action包是我新建的,不能在原有的service包下面,可能会产生冲突,具体是什么原因,我也不清楚,看不到它的源码。
justlearn 2010-05-06
  • 打赏
  • 举报
回复
而且你配置文件里没有引入struts-default
是这个插件会自动引入还是根本不需要struts-default呢

比如我这边没用你那个插件,是这样的
<package name="userinfo" extends="struts-default" namespace="/" >
liuyyuns 2010-05-06
  • 打赏
  • 举报
回复
我在访问的时候老是报404的错误,找不到指定的文件。
justlearn 2010-05-06
  • 打赏
  • 举报
回复
你的namespace呢?
study/teacher.jsp前面是不是得有个斜线?
Convention没用过,不是很清楚
liuyyuns 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 justlearn 的回复:]
首先,你的说下struts版本1.x和2.x差距很大
昨天听你说用的jdk1.4,我就很怀疑你用的struts1.2的
[/Quote]
我先说一下,昨天是由于特殊的需求只能用jdk1.4的,今天使用的myeclipse6.5开发的,jdk是5.0的,springside里面的是自动集成了struts2和spring3.0的。我下面把我的整个的struts.xml贴出来。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.convention.default.parent.package" value="crud-default" />
<constant name="struts.convention.package.locators" value="view" />
<constant name="struts.convention.package.locators.basePackage" value="com.test" />

<!-- 用于CRUD Action的parent package -->
<package name="crud-default" extends="convention-default">
<!-- 基于paramsPrepareParamsStack,
增加store interceptor保证actionMessage在redirect后不会丢失 -->
<interceptors>
<interceptor-stack name="crudStack">
<interceptor-ref name="store">
<param name="operationMode">AUTOMATIC</param>
</interceptor-ref>
<interceptor-ref name="paramsPrepareParamsStack" />
</interceptor-stack>
</interceptors>

<default-interceptor-ref name="crudStack" />

<action name="teacher" class="com.test.service.study.TeacherAction">
<result name="success" type="redirect">study/teacher.jsp</result>
<result name="error" type="redirect">error.jsp</result>
</action>
</package>
<!--
使用Convention插件,实现约定大于配置的零配置文件风格.
特殊的Result路径在Action类中使用@Result设定.
-->
</struts>
So_So 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 liuyyuns 的回复:]
我变成小写的也还是不行,控制台不报错了,但是输出来下面的东西,
000000000000
2010-05-06 14:49:50,125 [http-8100-Processor23] INFO [com.test.service.study.TeacherAction] -
[/Quote]
您现在用的是strust2 的吧

请问你具体需要什么?

你输出什么东西?

是你调用的东西没调用到?


  • 打赏
  • 举报
回复
[Quote=引用 9 楼 liuyyuns 的回复:]

我变成小写的也还是不行,控制台不报错了,但是输出来下面的东西,
000000000000
2010-05-06 14:49:50,125 [http-8100-Processor23] INFO [com.test.service.study.TeacherAction] -
[/Quote]
你还是贴点代码吧。。你是怎么测得。不报错还不行,那要啥效果。
justlearn 2010-05-06
  • 打赏
  • 举报
回复
首先,你的说下struts版本1.x和2.x差距很大
昨天听你说用的jdk1.4,我就很怀疑你用的struts1.2的
liuyyuns 2010-05-06
  • 打赏
  • 举报
回复
我变成小写的也还是不行,控制台不报错了,但是输出来下面的东西,
000000000000
2010-05-06 14:49:50,125 [http-8100-Processor23] INFO [com.test.service.study.TeacherAction] -
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 liuyyuns 的回复:]

引用 3 楼 faith_wolf 的回复:
我晕 自动生成的啊 ..哥们 你是要spring的配置 还是 struts的配置啊

struts的配置 可以自动生成 你new 一个action 类 然后去XML 里面找相应的配置 其他的 依照自动生成的就OK 了

springside里面的struts.xml的配置,在它里面可以指定自己的action,我的action是这样的,
X……
[/Quote]

result name = “小写”
  • 打赏
  • 举报
回复


Spring 配置action
<bean id="userAction" class="com.sys.action.UserAction">
<property name="userManager" ref="userManager"></property> <!-- 注入service -->
</bean>


struts.xml 中使用action

<action name="user_*" class="userAction" method="{1}">
<result name="login_success" type="redirect">article_main.action</result>
<result name="res_success" type="redirect">article_main.action</result>
<result name="login_error">index.jsp</result>
<result name="index">index.jsp</result>
<result name="eidt_error">edit.jsp</result>
<result name="success">index.jsp</result>
<result name="edit_pass">edit.jsp</result>
<result name="body_main">body.jsp</result>
<result name="adminLogin" type="redirect">admin_articleCateList.action</result>
<interceptor-ref name="myStack"></interceptor-ref>
</action>
liuyyuns 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 faith_wolf 的回复:]
我晕 自动生成的啊 ..哥们 你是要spring的配置 还是 struts的配置啊

struts的配置 可以自动生成 你new 一个action 类 然后去XML 里面找相应的配置 其他的 依照自动生成的就OK 了
[/Quote]
springside里面的struts.xml的配置,在它里面可以指定自己的action,我的action是这样的,

<action name="teacher" class="com.test.service.study.TeacherAction">
<result name="SUCCESS" type="dispatcher">study/teacher.jsp</result>
<result name="ERROR" type="dispatcher">error.jsp</result>
</action>

但是不好使。
  • 打赏
  • 举报
回复
奥,sorry。
在struts.xml>配置action?
<action name="test" class="teacherAction" >
<result/>
</action>
So_So 2010-05-06
  • 打赏
  • 举报
回复
1楼说的是 spring的配置
So_So 2010-05-06
  • 打赏
  • 举报
回复
我晕 自动生成的啊 ..哥们 你是要spring的配置 还是 struts的配置啊

struts的配置 可以自动生成 你new 一个action 类 然后去XML 里面找相应的配置 其他的 依照自动生成的就OK 了

liuyyuns 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zhangkai08111 的回复:]
。。。。。。。。。。。。。。。。。。。类在哪个包和你配置有啥关系么。
<bean id = "" class = "com.xx.xx.xx.TeacherAction" />clas指定不就行了。。
[/Quote]
你给的方法我试了一下,bean没有id属性,报错。
  • 打赏
  • 举报
回复
。。。。。。。。。。。。。。。。。。。类在哪个包和你配置有啥关系么。
<bean id = "" class = "com.xx.xx.xx.TeacherAction" />clas指定不就行了。。

81,095

社区成员

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

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