经常使用的几种Result组件 1)JSP响应 dispatcher :采用请求转发方式调用JSP组件响应。 redirect:采用请求重定向方式调用JSP组件响应。(在重定向后,原request和action都被销毁掉,所以在JSP获取不到值) 使用格式以下: <result type="dispatcher"> <param name="location">/msg.jsp</param> </result> 或者使用简写 <result type="dispatcher"> /msg.jsp </result> 2)Action响应 delete.action?id=1---->DeleteAction--->ListAction--->list.jsp redirectAction:采用重定向方式发出一个*.action请求 chain:采用转发方式发出一个*.action请求 使用格式以下: 调用不一样命名空间的action时: <result type="redirectAction"> <param name="actionName">请求名</param> <param name="namespace">命名空间</param> </result> 调用相同命名空间的action时: <result type="redirectAction"> 请求名 </result> -->*.action--->Action1--chain-->Action2---chain-->Action3 3)流响应 典型功能:验证码和下载。 stream:能够将Action中的一个InputStream类型属性以流方式响应输出。 使用格式以下: <result type="stream"> <param name="inputName">Action属性</param> </result> 4)JSON响应 负责对Ajax请求进行数据响应。 json:能够将Action中的一个属性或多个属性以json格式响应输出 使用格式以下: 若是须要返回一个属性值 <result type="json"> <param name="root">Action属性</param> </result> 若是须要返回多个属性值 <result type="json"> <param name="includeProperties"> Action属性1,Action属性2 </param> </result> 若是须要返回全部属性值 <result type="json"></result> 注意:使用前须要引入struts-json-plugin.jar,而后将<package>元素的extends设置成"json-default"