Spring mvc mapping + displaytag分页/排序

时间:2013-04-16 12:25:22

标签: spring model-view-controller mapping displaytag

我正在尝试在我的项目中使用显示标记库。

JSP:

<display:table name="rooms" class="table table-striped" pagesize="5">
    <display:column property="name" titleKey="crs.admin.room.roomName" sortable="true" />
    <display:column property="capacity" />
</display:table>

控制器:

@Controller
public class RoomController {
....
@RequestMapping(value = "/roomManagement*", method = RequestMethod.GET)
public ModelAndView get() {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("roomManagement");
    modelAndView.addObject("rooms", roomService.findAll());
    return modelAndView;
}

查看解析器:

<bean id="jspViewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass"
              value="org.springframework.web.servlet.view.JstlView"/>
    <property name="prefix" value=""/>
    <property name="suffix" value=".jsp"/>
</bean>

当我用它打开页面时,我的链接如下:

http://localhost:8081/roomManagement

但点击分页/排序链接后,它看起来像:

http://localhost:8081/roomManagement.jsp?d-49653-s=0&d-49653-o=2

由于“.jsp”后缀,我的控制器无法处理此请求,并且不会将房间列表放入视图中。 我应该怎么处理它?<​​/ p>

1 个答案:

答案 0 :(得分:2)

好的,这很简单,我添加了

 requestURI="/roomManagement"

要显示的参数:table tag