contextpath

Spring MVC Request URLs in JSP

大兔子大兔子 提交于 2019-11-28 18:47:32
I am writing a web application using Spring MVC. I am using annotations for the controllers, etc. Everything is working fine, except when it comes to actual links in the application (form actions, <a> tags, etc.) Current, I have this (obviously abbreviated): //In the controller @RequestMapping(value="/admin/listPeople", method=RequestMethod.GET) //In the JSP <a href="/admin/listPeople">Go to People List</a> When I directly enter the URL like "http://localhost:8080/MyApp/admin/listPeople", the page loads correctly. However, the link above does not work. It looses the application name "MyApp".

How is using “<%=request.getContextPath()%>” better than “../”

不问归期 提交于 2019-11-28 17:04:18
I have worked on number of J2EE projects where the view layer is JSP. In most projects, I have seen that we reference external resources i.e. images, javascript, jsp's, css etc. using the contextPath in the scriptlet. The code is as follows, <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>GC Demo Using HandlebarsJS</title> <script type="text/javascript" src="<%=request.getContextPath()%>/js/jqueryUI-AutoComplete/jquery-1.9.1.js"></script> <script type="text/javascript" src="<%

Get the web application context path from META-INF/context.xml to produce an outcome for navigating

最后都变了- 提交于 2019-11-28 13:01:22
I have a primefaces web application running on tomcat 8. In META-INF/context.xml I defined the following: <?xml version="1.0" encoding="UTF-8"?> <Context antiJARLocking="true" path="/syslac"/> While in my view xhtml page I have this fragment code where p:commandButton has a oncomplete tag that will execute the handleLoginRequest function. <h:form> <h:panelGrid columns="2" cellpadding="5"> <h:outputLabel for="username" value="Usuario:" /> <p:inputText value="#{loginBean.usuarioVendedor.usuarioSistema}" id="username" required="true" label="username" /> <h:outputLabel for="password" value=

Spring MVC Request URLs in JSP

心不动则不痛 提交于 2019-11-27 11:50:07
问题 I am writing a web application using Spring MVC. I am using annotations for the controllers, etc. Everything is working fine, except when it comes to actual links in the application (form actions, <a> tags, etc.) Current, I have this (obviously abbreviated): //In the controller @RequestMapping(value="/admin/listPeople", method=RequestMethod.GET) //In the JSP <a href="/admin/listPeople">Go to People List</a> When I directly enter the URL like "http://localhost:8080/MyApp/admin/listPeople", the

Any clever ways of handling the context in a web app?

匆匆过客 提交于 2019-11-27 11:27:18
In Java, web apps are bundled in to WARs. By default, many servlet containers will use the WAR name as the context name for the application. Thus myapp.war gets deployed to http://example.com/myapp . The problem is that the webapp considers its "root" to be, well, "root", or simply "/", whereas HTML would consider the root of your application to be "/myapp". The Servlet API and JSP have facilities to help manage this. For example, if, in a servlet, you do: response.sendRedirect("/mypage.jsp"), the container will prepend the context and create the url: http://example.com/myapp/mypage.jsp ".

How is using “<%=request.getContextPath()%>” better than “../”

拈花ヽ惹草 提交于 2019-11-27 10:08:56
问题 I have worked on number of J2EE projects where the view layer is JSP. In most projects, I have seen that we reference external resources i.e. images, javascript, jsp's, css etc. using the contextPath in the scriptlet. The code is as follows, <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>GC Demo Using HandlebarsJS</title> <script type="text/javascript" src="<%=request

Get the web application context path from META-INF/context.xml to produce an outcome for navigating

蓝咒 提交于 2019-11-27 07:38:52
问题 I have a primefaces web application running on tomcat 8. In META-INF/context.xml I defined the following: <?xml version="1.0" encoding="UTF-8"?> <Context antiJARLocking="true" path="/syslac"/> While in my view xhtml page I have this fragment code where p:commandButton has a oncomplete tag that will execute the handleLoginRequest function. <h:form> <h:panelGrid columns="2" cellpadding="5"> <h:outputLabel for="username" value="Usuario:" /> <p:inputText value="#{loginBean.usuarioVendedor

Any clever ways of handling the context in a web app?

南笙酒味 提交于 2019-11-26 15:35:16
问题 In Java, web apps are bundled in to WARs. By default, many servlet containers will use the WAR name as the context name for the application. Thus myapp.war gets deployed to http://example.com/myapp. The problem is that the webapp considers its "root" to be, well, "root", or simply "/", whereas HTML would consider the root of your application to be "/myapp". The Servlet API and JSP have facilities to help manage this. For example, if, in a servlet, you do: response.sendRedirect("/mypage.jsp"),

How to use relative paths without including the context root name?

北城余情 提交于 2019-11-26 00:09:04
问题 To working my static file (CSS, JS) I have to write absolute path like /AppName/templates/style/main.css . Is there any solution, that I could write relative path like style/main.css ? 回答1: If your actual concern is the dynamicness of the webapp context (the "AppName" part), then just retrieve it dynamically by HttpServletRequest#getContextPath(). <head> <link rel="stylesheet" href="${pageContext.request.contextPath}/templates/style/main.css" /> <script src="${pageContext.request.contextPath}

What are the recommendations for html <base> tag?

被刻印的时光 ゝ 提交于 2019-11-25 21:46:17
问题 I\'ve never seen <base> HTML tag actually used anywhere before. Are there pitfalls to its use that means I should avoid it? The fact that I have never noticed it in use on a modern production site (or any site) makes me leery of it, though it seems like it might have useful applications for simplifying links on my site. Edit After using the base tag for a few weeks, I did end up finding some major gotchas with using the base tag that make it much less desirable than it first appeared.