SpringMVC 的 @RequestParam required 失效的问题,请教各位。

controller部分代码如下:

    @RequestMapping(value = "/u/info/infoMonitorFromFriend" )
    public String infoMonitorFromFriend(  
        @RequestParam(required=false,defaultValue="",value="attid") int[] attid,    //信息的属性额 1 原创         2 转发    7回复   
        @RequestParam(required=false,defaultValue="",value="keyid") int[] keyid,  //关键词id 过滤
        @RequestParam(required=false,defaultValue="",value="stat") int[] stat, // 状态
        @RequestParam(required=false,defaultValue="",value="contentkey") String  contentkey, //  内容包涵的词
        @RequestParam(required=false,defaultValue="",value="userkey") String userkey, // 用户名包涵的内容
        @RequestParam(value="page",defaultValue="1") Integer page,
        @RequestParam(value="pageSize",defaultValue="5") Integer pageSize,
        HttpServletRequest request, HttpServletResponse response, ModelMap model ) throws IOException 
    {

 

当在Spring配置文件中用

<mvc:annotation-driven />

 **/u/info/infoMonitorFromFriend?page=1&pageSize=5 这样的URL可以放到controller。

但是当我用,

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter

来配置,如下

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
        <property name="order" value="0" />            
    </bean>     
    
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">  
        <property name="messageConverters">    
            <list>    
                <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />  
                <bean class="org.springframework.http.converter.StringHttpMessageConverter" /> 
                <bean class="org.springframework.http.converter.ResourceHttpMessageConverter" /> 
                <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter" /> 
                <bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter" /> 
                <bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" />   
                <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" > 
                    <property name="supportedMediaTypes">  
                        <list>
                            <value>text/html;charset=UTF-8</value>
                        </list>
                    </property>  
                </bean>
            </list>    
        </property>    
    </bean>    

 

 **/u/info/infoMonitorFromFriend?page=1&pageSize=5 这样的URL就会返回404.

 

求解答~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

查看全部
xuganggogo
xuganggogo
2013/03/19 19:53
  • spring
  • mvc
  • springmvc
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

0个回复