gpt4 book ai didi

java - 如何在 spring mvc 应用程序中打开弹出窗口

转载 作者:行者123 更新时间:2023-11-30 03:42:07 25 4
gpt4 key购买 nike

我有以下网络应用程序结构:

enter image description here

addTerminal.jsp里面我写了以下内容:

....
<a href="#" class="open-map" onclick="showMap(55,22)">show map</a>
...
function showMap(lat,lng) {
window.open('map.html?lat='+lat+'&lng='+lng, 'map', 'width=600,height=400');
}
....

但是由于客户端无法访问 WEB-INF 文件夹,因此单击 href 时我看到 404

您能否建议如何解决我的问题?

我认为我可以将 map.html 放入 webapp 文件夹中,但我认为存在另一个修复。应用技术栈:

Tomcat + Hibernate + SpringMVC

web.xml:

<web-app id="WebApp_ID" version="2.4"
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/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>Spring MVC Application</display-name>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/webContext.xml</param-value>
</context-param>
<!-- Spring MVC -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/webContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>charsetFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>charsetFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>

最佳答案

您只需创建一个 Controller 来处理对 map.html 的请求。

类似的东西:

@RequestMapping("/map.html")
public String popup(@RequestParam("lat") String lat, @RequestParam("lng") String lng){
// your code here...
return "map";
}

关于java - 如何在 spring mvc 应用程序中打开弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26605297/

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