gpt4 book ai didi

java - Spring ViewResolver问题

转载 作者:行者123 更新时间:2023-12-01 15:54:45 26 4
gpt4 key购买 nike

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

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

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

有什么想法吗?

<小时/>

更新

代码:

<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" />

谢谢回复

最佳答案

View 解析器会将其自己的前缀后缀属性与您从 Controller 返回的名称结合起来。

在这种情况下,它将使用

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

因此将尝试在 webapp 基目录中查找名为

的文件
/cusbilman/resources/static//jsp/cusbilman/main/billportmain.jsp.html

这对我来说看起来严重错误。

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

关于java - Spring ViewResolver问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5297041/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com