Spring ViewResolver问题

发布于 2024-10-21 23:26:09 字数 2070 浏览 0 评论 0原文

我的应用程序一直成功运行,直到我在其中添加 org.springframework.web.servlet.view.InternalResourceViewResolver 。它给出了错误:

javax.servlet.ServletException:无法解析名为“cusbilman”的 servlet 中名为“/jsp/cusbilman/main/billportmain.jsp”的视图

我认为它破坏了默认的重定向方法:

有什么想法吗?


更新

代码:

<bean id="htmlViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/cusbilman/resources/static/"/>
        <property name="suffix" value=".html"/>
        <property name="viewNames">
            <list>
                <value>html1</value>
            </list>
        </property>
    </bean>

旧bean定义:

<bean id="billingPortalMainController" class="com.tt.cusman.cusbilman.main.view.BillingPortalMainController" >
<property name="commandName"><value>dummy</value></property>            
<property name="commandClass"><value>com.tt.cusman.cusbilman.main.view.command.DummyObject</value></property>   
<property name="sessionForm"><value>false</value></property>
<property name="formView"><value>/jsp/cusbilman/main/billportmain.jsp</value></property>
<property name="successView"><value>/jsp/cusbilman/main/billportmain.jsp</value></property>
<property name="searchView"><value>/../cusinfman/search/search.html</value></property>
<property name="postPaidHome"><value>/cusbilman/cusbilman/invoices.html?page=new</value></property>
<property name="prePaidHome"><value>/cusbilman/cusbilman/prepaid/main.html?page=new</value></property>
<property name="emptyForm"><value>/cusbilman/jsp/cusbilman/main/emptyForm.jsp</value></property>
<property name="cusbilmanMainQdbDao" ref="cusbilmanMainQdbDao" />

感谢您的回复

My application was running succestfully until I add a org.springframework.web.servlet.view.InternalResourceViewResolver in it. It gives the error:

javax.servlet.ServletException: Could not resolve view with name '/jsp/cusbilman/main/billportmain.jsp' in servlet with name 'cusbilman'

I think it broke the default redirection method:

Any ideas?


Update

The code:

<bean id="htmlViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/cusbilman/resources/static/"/>
        <property name="suffix" value=".html"/>
        <property name="viewNames">
            <list>
                <value>html1</value>
            </list>
        </property>
    </bean>

Old bean definition:

<bean id="billingPortalMainController" class="com.tt.cusman.cusbilman.main.view.BillingPortalMainController" >
<property name="commandName"><value>dummy</value></property>            
<property name="commandClass"><value>com.tt.cusman.cusbilman.main.view.command.DummyObject</value></property>   
<property name="sessionForm"><value>false</value></property>
<property name="formView"><value>/jsp/cusbilman/main/billportmain.jsp</value></property>
<property name="successView"><value>/jsp/cusbilman/main/billportmain.jsp</value></property>
<property name="searchView"><value>/../cusinfman/search/search.html</value></property>
<property name="postPaidHome"><value>/cusbilman/cusbilman/invoices.html?page=new</value></property>
<property name="prePaidHome"><value>/cusbilman/cusbilman/prepaid/main.html?page=new</value></property>
<property name="emptyForm"><value>/cusbilman/jsp/cusbilman/main/emptyForm.jsp</value></property>
<property name="cusbilmanMainQdbDao" ref="cusbilmanMainQdbDao" />

Thanks for the reply

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的奇迹 2024-10-28 23:26:09

视图解析器会将其自己的 prefixsuffix 属性与您从控制器返回的名称结合起来。

在这种情况下,它将使用

"/cusbilman/resources/static/" + "/jsp/cusbilman/main/billportmain.jsp" + ".html"

并因此尝试在 webapp 基本目录中查找名为的文件,

/cusbilman/resources/static//jsp/cusbilman/main/billportmain.jsp.html

该文件对我来说看起来严重错误。

您需要整理视图解析器前缀和 JSP 路径。

The view resolver will combine it's own prefix and suffix properties with the name you return from your controller.

In this case, it will use

"/cusbilman/resources/static/" + "/jsp/cusbilman/main/billportmain.jsp" + ".html"

and will therefore try and look for a file inside the webapp base directory named

/cusbilman/resources/static//jsp/cusbilman/main/billportmain.jsp.html

which looks seriously wrong to me.

You need to sort out your view resolver prefix and JSP paths.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文