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

ssh协作,这样配置是否正确

2012-09-11 
ssh合作,这样配置是否正确struts 2.3 spring3.1 hibernate3.6web.xmlcontext-paramparam-namecontextC

ssh合作,这样配置是否正确
struts 2.3 spring3.1 hibernate3.6
web.xml

  <context-param>    <param-name>contextConfigLocation</param-name>    <param-value>classpath:root-context.xml</param-value>  </context-param>  <listener>    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  </listener>  <filter>    <filter-name>struts2</filter-name>    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  </filter>  <filter-mapping>    <filter-name>struts2</filter-name>    <url-pattern>/*</url-pattern>  </filter-mapping>

struts.xml
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" /> <package name="default" namespace="/" extends="json-default"> <action name="*_*" method="{2}"> <result>/WEB-INF/views/admin/{1}_list.jsp</result> </action> </package>

action代码
@Scope("prototype")@Controller("naviAction")public class NaviAction {private Navigation navi;public String add() {return "add";}//getter and setterpublic void setNavi(Navigation navi) {this.navi = navi;}}

页面
<form id="channel_form" action="Navi_add" method="post"><input name="navi.name" type="text"><input name="navi.rank" type="text"><input name="navi.link" type="text"><input name="navi.type" type="text"><input type="submit"></form>


提交的结果是navi对象里只有一个属性有值
浏览器请求中所有的属性都post了
debug,action中setNavi执行了几次,属性都是空,进入add方法后navi里只有一个属性有值。

不知道我这中使用方法有什么问题,为什么属性set不进去。

我的思路是spring注解管理bean,struts直接找spring里的action对象

热点排行