如何集成“旧的spring mvc控制器与jsp"和“vaadin7 ui"一起 [英] How to integrate "old spring mvc controllers with jsp" and "vaadin7 ui" together
问题描述
我正在尝试将 vaadin 与我的 spring mvc 应用程序集成.我有一些带有 jsp 文件的 url,spring mvc 控制器使用它们例如 :mysite.com/spring/mysite.com/spring/examplesmysite.com/spring/examples/1.jsp
I am trying to integrate vaadin with my spring mvc application. I have a some url with jsp files that spring mvc controller use them For example : mysite.com/spring/ mysite.com/spring/examples mysite.com/spring/examples/1.jsp
我想在此路径中添加 vaadin:mysite.com/vaadin/MainUI
I want to add vaadin in this path: mysite.com/vaadin/MainUI
这是我的 web.xml
here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.1"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd"
metadata-complete="true">
<display-name>vaadin-spring</display-name>
<!-- Turn off productionMode (off by default). Setting productionMode=true disables
debug features. In when this is off, you can show debug window by adding ?debug to
your application URL. Always set this true in production environment. -->
<context-param>
<param-name>productionMode</param-name>
<param-value>false</param-value>
<description>Vaadin production mode</description>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name>vaadin-spring</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>com.practice.vaadin_spring.VaadinSpringDemoApplication</param-value>
<description>Vaadin application class to start</description>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>vaadin-spring</servlet-name>
<url-pattern>/vaadin/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>vaadin-spring</servlet-name>
<url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>
<!-- spring -->
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>spring.profiles.active</param-name>
<param-value>local</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
这是我的弹簧主控制器:
Here is my spring main controller:
@Controller
@RequestMapping("/")
public class MainController {
@RequestMapping(value = "{jspFile}")
public String map(@PathVariable String jspFile) throws IOException {
return jspFile;
}
@RequestMapping(method = RequestMethod.GET)
public String map1() throws IOException {
return "index";
}
}
这是github中的工作示例(修复后)https://github.com/prilia/IntegrationSpringMvcVaadinUI
Here is working example (after fix) in github https://github.com/prilia/IntegrationSpringMvcVaadinUI
推荐答案
所以经过一些尝试,我最终得到了一个 JSP 编译异常,我认为这是合理的,因为您在 github 上提供了一个测试示例.到目前为止,这是我所做的:
So after some tries i've ended up with a JSP compile exception, which i believe is reasonable since you provided a test example on github. So far here's what i've done:
web.xml
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
主控制器.java
@Controller
@RequestMapping("/")
public class MainController { ...
spring-servlet.xml 我已经添加
spring-servlet.xml i've added
<bean name="spring" class="org.nli.deposit.controller.MainController" />
现在看来它解析了网址:
Now seems it resolves the url:
http://localhost:8080/springMvcTest/ 转到 JSP
http://localhost:8080/springMvcTest/vaadin 转到 Vaadin
它只是在 JSP 编译期间崩溃,但这是另一个问题.试试你的完整项目并告诉我!
it just crashes during JSP compilation, but that's a whole another question. Try on your complete project and let me know!
这篇关于如何集成“旧的spring mvc控制器与jsp"和“vaadin7 ui"一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!