« | July 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | |
| 公告 |
戒除浮躁,读好书,交益友 |
Blog信息 |
blog名称:邢红瑞的blog 日志总数:523 评论数量:1142 留言数量:0 访问次数:9673817 建立时间:2004年12月20日 |

| |
[j2ee]spring的ParameterMethodNameResolver的使用 原创空间, 软件技术
邢红瑞 发表于 2005/10/16 19:23:26 |
spring的ParameterMethodNameResolver的可以根据不同的参数执行不同方法,类似Struts的dyncaction下面有一个例子package ee.bug;
import java.util.ArrayList;import java.util.Date;import java.util.List;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.web.servlet.ModelAndView;import org.springframework.web.servlet.mvc.multiaction.MultiActionController;public class ProductController extends MultiActionController {
/** * Handles view */ public ModelAndView view(HttpServletRequest request, HttpServletResponse response) throws Exception {
response.getOutputStream().print("Viewing");
return null; }
/** * Handles index */ public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception { response.getOutputStream().print("index"); return null; } }配置文件 <bean id="productMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"> <property name="paramName"><value>method</value></property> <property name="defaultMethodName"><value>view</value></property> </bean> <bean id="productController" class="ee.bug.ProductController"> <property name="methodNameResolver"><ref local="productMethodNameResolver"/></property> </bean> <property name="paramName"><value>method</value></property>参数名为method 默认为action 输入view.do?method=view 显示Viewing输入view.do?method=indedx 显示index输入/view.do?method=fdsf 显示404错误 |
|
回复:spring的ParameterMethodNameResolver的使用 原创空间, 软件技术
dd(游客)发表评论于2012/10/9 9:20:10 |
以下引用lh(游客)在2006-11-27 18:08:40的评论:
很不错 |
|
回复:spring的ParameterMethodNameResolver的使用 原创空间, 软件技术
小智(游客)发表评论于2007/9/18 22:35:03 |
|
回复:spring的ParameterMethodNameResolver的使用 原创空间, 软件技术
sky(游客)发表评论于2007/8/16 9:06:43 |
|
回复:spring的ParameterMethodNameResolver的使用 原创空间, 软件技术
lh(游客)发表评论于2006/11/27 18:08:40 |
|
» 1 »
|