如何将 "old spring mvc controllers with jsp" 和 "vaadin7 ui" 整合在一起
How to integrate "old spring mvc controllers with jsp" and "vaadin7 ui" together
我正在尝试将 vaadin 与我的 spring mvc 应用程序集成。
我有一些 url 和 jsp 文件,spring mvc 控制器使用它们
例如 :
我的网站.com/spring/
mysite.com/spring/示例
mysite.com/spring/examples/1.jsp
我想在此路径中添加 vaadin:
我的网站.com/vaadin/MainUI
这是我的 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>
这是我的 spring 主控制器:
@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
所以在一些尝试之后,我得到了一个 JSP 编译异常,我认为这是合理的,因为你在 github 上提供了一个测试示例。
到目前为止,这是我所做的:
web.xml
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
MainController.java
@Controller
@RequestMapping("/")
public class MainController { ...
spring-servlet.xml 我已经添加了
<bean name="spring" class="org.nli.deposit.controller.MainController" />
现在似乎解决了 url:
http://localhost:8080/springMvcTest/ 转到 JSPs
http://localhost:8080/springMvcTest/vaadin 去 Vaadin
它只是在 JSP 编译期间崩溃,但这完全是另一个问题。
试用您的完整项目并告诉我!
我正在尝试将 vaadin 与我的 spring mvc 应用程序集成。 我有一些 url 和 jsp 文件,spring mvc 控制器使用它们 例如 : 我的网站.com/spring/ mysite.com/spring/示例 mysite.com/spring/examples/1.jsp
我想在此路径中添加 vaadin: 我的网站.com/vaadin/MainUI
这是我的 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>
这是我的 spring 主控制器:
@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
所以在一些尝试之后,我得到了一个 JSP 编译异常,我认为这是合理的,因为你在 github 上提供了一个测试示例。 到目前为止,这是我所做的:
web.xml
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
MainController.java
@Controller
@RequestMapping("/")
public class MainController { ...
spring-servlet.xml 我已经添加了
<bean name="spring" class="org.nli.deposit.controller.MainController" />
现在似乎解决了 url:
http://localhost:8080/springMvcTest/ 转到 JSPs
http://localhost:8080/springMvcTest/vaadin 去 Vaadin
它只是在 JSP 编译期间崩溃,但这完全是另一个问题。 试用您的完整项目并告诉我!