gpt4 book ai didi

java - 使用 html 页面而不是 jsp 页面时出现错误

转载 作者:行者123 更新时间:2023-12-02 11:17:02 25 4
gpt4 key购买 nike

我想使用html页面而不是使用 jsp页。但是在使用 html 页面时出现错误。但如果我使用 jsp 页面,我不会收到任何错误。

当我使用<property name="suffix" value=".jsp"/>时我没有收到任何错误。这是我的spring-servlet.xml文件

http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

<mvc:annotation-driven/>
<context:component-scan base-package="org.avijit"/>
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".html"/>
</bean>

我的Controller类是

 package org.avijit;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class BaseController {
@RequestMapping(value="/", method = RequestMethod.GET)
public String homePage()
{
return "welcomePage";
}
}

最佳答案

我终于得到答案了。我已将我的 viewresolver 类更改为

<bean
id="templateResolver"
class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver"
p:prefix="/WEB-INF/views/"
p:suffix=".html"
p:templateMode="HTML5"

></bean>

<bean id="templateEngine"
class="org.thymeleaf.spring4.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
</bean>

<bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
</bean>

现在一切正常! :)

关于java - 使用 html 页面而不是 jsp 页面时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50197991/

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