我正在开发一个简单的 spring 应用程序。我有一些jsp,我想更改jsp 的名称和URL。我改变了 Controller :
@RequestMapping(value = "/simpleForm.html", method = RequestMethod.GET)
public void simpleForm(Model model) {
model.addAttribute(new User());
}
至
@RequestMapping(value = "/newName.html", method = RequestMethod.GET)
public void simpleForm(Model model) {
model.addAttribute(new User());
}
旧的 simpleForm.jsp
的名称改为 newName.jsp
user
是我在 表单中使用的类simpleform.jsp
我无法让它发挥作用。我收到 404 提示找不到 simpleform.jsp。我陷入了困境。
编辑:我的 View 解析器标签:
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
我的网址模式是这样的:
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/forms/*</url-pattern>
</servlet-mapping>
I've found out that all of the links are getting the same error () resource not available. Even the ones that I didn't change the name of.
我还尝试直接从 newName.jsp
开始。还是同样的错误!
最佳答案
更改:
@RequestMapping(value = "/newName.html", method = RequestMethod.GET)
至:
@RequestMapping(value = "/newName.jsp", method = RequestMethod.GET)
关于java - 更改 .JSP 文件的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11518567/