java - Spring ViewResolver问题

标签 java spring-mvc

我的应用程序一直成功运行,直到我在其中添加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/

相关文章:

java - 使用 RedirectAttributes 作为 bean spring mvc

java - Lanterna SwingTerminal 不会显示

java - 单击时更改 gridview 单元格的颜色

java - Hibernate + spring获取最新的lazy 1 to N属性值

java - Autowiring Bean 列表并分别识别它们

java - 如何在 spring Controller 中创建 jwt 图像

java - 为什么spring boot war不生成web.xml

java - 没有找到适用于零实际参数的构造函数/方法 - Apache Spark Java

java - 内部类 Action 监听器

java - 检测并发修改?