0

几天前,此配置有效,但现在我得到了:

javax.servlet.ServletException: Could not resolve view with name '' in servlet with name 'XXX'

为了:

http://localhost:8081/resourceArea/save

我的控制器看起来像:

@Controller
@RequestMapping("/resourceArea")
public class ResourceAreaController{
....
@RequestMapping(value = "/save", method = RequestMethod.POST)
public String save(@ModelAttribute @Valid ResourceArea aEntity, BindingResult aBindingResult, Model aModel, SessionStatus status,
                   HttpSession session) {
...
}

我的视图配置了它们之前完美运行的图块:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
    "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
    "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="base.definition"
            template="/WEB-INF/pages/layouts/layout.jsp">
    <put-attribute name="title" value="Pit 2 Web Demo"/>
    <put-attribute name="header" value="/WEB-INF/pages/layouts/header.jsp"/>
    <put-attribute name="menu" value="/WEB-INF/pages/layouts/menu.jsp"/>
    <put-attribute name="content" value=""/>
    <put-attribute name="footer" value="/WEB-INF/pages/layouts/footer.jsp"/>
</definition>

<definition name="home" extends="base.definition">
    <put-attribute name="content" value="/WEB-INF/pages/home.jsp"/>
</definition>

<definition name="denied" extends="base.definition">
    <put-attribute name="content" value="/WEB-INF/pages/denied.jsp"/>
</definition>

<definition name="/*/*" extends="base.definition">
    <put-attribute name="title" value="{2} {1}"/>
    <put-attribute name="content" value="/WEB-INF/pages/{1}/{2}.jsp"/>
</definition>

<definition name="/raw/*/*" template="/WEB-INF/pages/layouts/empty.jsp">
    <put-attribute name="content" value="/WEB-INF/pages/{1}/{2}.jsp"/>
</definition>

</tiles-definitions>

这很奇怪,因为这只发生在保存动作中。

4

1 回答 1

0

改变你的方法

public String save(...)

public void save(...)

或者作为替代方案(并且由于您的save方法是一个POST动作),您可能希望实现PostRedirectGet 范例

public String save(...){
    // do whatever you want here
    return "redirect:another view";
}
于 2013-04-29T06:45:38.283 回答