标签: contextpath

Web上下文根是否有内置的Spring环境变量?

我正在使用Spring Web Services将服务公开为Web服务.在我的spring配置xml文件中,我有一个bean,它是DefaultWsdl11Definition的一个实例.需要设置的属性之一是locationUri.这需要是一个完全合格的Uri,但是当应用程序从dev升级到uat和生产时,我不想更改此值.Spring知道Web应用程序上下文根是什么,所以我可以在配置文件中指定一个变量来访问它吗?

就像是:

<bean id="myWebServices"
    class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
    <property name="schemaCollection">
        <bean
            class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
            <property name="xsds" ref="xsdList"/>
            <property name="inline" value="true" />
        </bean>
    </property>
    <property name="portTypeName" value="myWebServices" />
    <property name="locationUri" value="${webContextRoot}/webServices" />
</bean>
Run Code Online (Sandbox Code Playgroud)

java spring spring-ws contextpath

12
推荐指数
2
解决办法
1万
查看次数

什么是在Angular JS中识别上下文路径的更好方法

我将我的Web应用程序部署到具有应用程序上下文的tomcat.例如,我的URL看起来像这样.

http://localhost:8080/myapp
Run Code Online (Sandbox Code Playgroud)

myapp - 这里是应用程序上下文.

现在在Angular服务中如果我想调用webservice说getusers.我的网址应该是这个/myapp/getusers.但我想避免硬编码应用程序上下文,因为它可能会从一个部署更改为另一个部署.我设法从中找出了contextpath,$window.location.pathname但它看起来非常愚蠢.有没有更好的办法?

仅供参考我使用Spring MVC来提供宁静的服务.

spring-mvc contextpath angularjs

12
推荐指数
3
解决办法
2万
查看次数

Jboss中的上下文路径

目前在JBOSS中部署了一场战争.如果我想在Jboss中找出WAR的上下文路径,我应该在哪里查看?在server.xml?

jboss contextpath

9
推荐指数
1
解决办法
2万
查看次数

在webapps /中使用autodeploy在Tomcat中指定嵌套的上下文路径

我知道在默认的Tomcat 8配置中,我可以将文件foo.war文件放入webapps/目录中,Tomcat将使用上下文路径自动部署我的Web应用程序/foo/.

如果我想要上下文路径,我会使用什么WAR文件名/foo/bar

tomcat web-applications contextpath tomcat8

9
推荐指数
1
解决办法
517
查看次数

如何在Servlet版本2.4的init()方法中获取ContextPath

我正在使用版本2.4,Servlet我需要ContextPath通过init()在服务器启动时调用的方法,所以我没有任何可以调用的Request对象,getContextPath()因为Servlet版本我没有getContextPath()方法ServletContext.

有办法以ContextPath()某种方式得到这个吗?

java servlets contextpath

7
推荐指数
1
解决办法
1万
查看次数

将 Web 应用程序升级到 Spring Boot 2.4 后的 IllegalStateException

升级到 Spring Boot 2.4 后,我的 Web 应用程序不再启动。它抛出以下错误:

Unable to locate the default servlet for serving static content. Please set the 'defaultServletName' property explicitly.
Run Code Online (Sandbox Code Playgroud)

我正在使用以下代码来更改上下文路径,我的研究指出这是“罪魁祸首”(更改上下文路径):

@Bean
public ServletWebServerFactory servletContainer() 
{
    String tomcatPort = environment.getProperty("tomcatPort");
    
    TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
    tomcat.setPort(tomcatPort != null ? Integer.parseInt(tomcatPort) : 8080);
    tomcat.setContextPath("/Carbon");
    tomcat.setBaseDirectory(new File(System.getenv("MDHIS3_HOME")));
    
    setTomcatProtocol(tomcat);
    
    return tomcat;
}
Run Code Online (Sandbox Code Playgroud)

我有以下方法,我可以看到它可以用来传递 defaultServletName 但我不知道我应该传递什么值:

@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) 
{
    configurer.enable();
}
Run Code Online (Sandbox Code Playgroud)

这在 Spring Boot 2.3.4 上运行良好。我在那里传递什么值?是主控制器的名字吗?

java tomcat servlets contextpath spring-boot

7
推荐指数
1
解决办法
1749
查看次数

Eclipse,Tomcat项目上下文根是eclipse文件夹

我在配置Tomcat项目时遇到了一些问题.简而言之,我正在开发一个动态网页项目,但似乎对我运行应用程序的位置存在一些困惑.

运行以下代码

File f = new File("");
System.err.println(f.getAbsolutePath());
Run Code Online (Sandbox Code Playgroud)

产生输出C:/Eclipse恰好是我运行Eclipse的地方.通常情况下,我希望这是输出目录,但这次并非如此.

我的eclipse项目配置为将myProject/WebContent/WEB-INF/classes作为输出文件夹

如何配置到所需的目录?现在我需要使用绝对路径,这对于项目的所有成员都不起作用.

java eclipse enterprise tomcat contextpath

6
推荐指数
1
解决办法
6763
查看次数

SpringBoot 将上下文路径添加到 Actuator 端点

我通过将上下文路径设置为 /myservice 来运行我的 springboot 应用程序。这会导致附加在 URL- http://localhost:8080/myservice/actuator/ 上公开的所有执行器端点,而我只需要 http://localhost:8080/actuator/。有没有办法告诉 springboot 忽略附加上下文路径到执行器端点(通过 DispatcherServlet 或 CXFServlet 或任何东西)请帮忙。

contextpath spring-boot spring-boot-actuator

6
推荐指数
1
解决办法
3293
查看次数

输出链接和graphicImage之间的EL上下文路径评估差异

我正在使用以下内容在我们的应用程序中获取帮助文档.我的问题是,在<h:graphicImage>正确评估上下文路径时,将其评估为h:outputLink空.我一直在使用这两种尝试$,并#h:outputLink因为我知道他们有不同的考核时间.

两个EL表达式的评估方式有何不同?

<h:outputLink value="${pageContext.servletContext.contextPath}/services/help.pdf">
    <h:graphicImage 
        url="${pageContext.servletContext.contextPath}/images/help.png" 
        alt="Online Help"/>
</h:outputLink>
Run Code Online (Sandbox Code Playgroud)

jsf el contextpath

5
推荐指数
1
解决办法
9792
查看次数

访问上下文路径(根文件夹)在 Spring Boot 应用程序中不显示登录页面

在我的Spring Boot(2.0)应用程序中,我在我的application.properties文件中设置了上下文路径,如下所示

server.servlet.context-path=/myApp
Run Code Online (Sandbox Code Playgroud)

另外,我有以下安全配置类扩展 WebSecurityConfigurerAdapter

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // TODO Auto-generated method stub


        http
        .csrf().disable()
        .authorizeRequests()
        .antMatchers(HttpMethod.GET,"/uifiles/dist/css/**").permitAll()
        .antMatchers(HttpMethod.GET,"/uifiles/plugins/icheck-bootstrap/**").permitAll()
        .antMatchers(HttpMethod.GET,"/uifiles/plugins/fontawesome-free/css/**").permitAll()
        .antMatchers(HttpMethod.GET,"/css/**").permitAll()
        .antMatchers(HttpMethod.GET, "/uifiles/**").permitAll()
        .antMatchers(HttpMethod.GET, "/error/**").permitAll()
        .antMatchers(HttpMethod.GET,"/files/**").permitAll()
        .antMatchers(HttpMethod.GET,"/files/fonts/**").permitAll()
        .antMatchers(HttpMethod.GET,"/files/images/**").permitAll()
        .and()
        .authorizeRequests().antMatchers("/login").permitAll()
        .anyRequest().authenticated()
        .and()
        .formLogin()
        .loginPage("/login")
        .successForwardUrl("/home")
        .defaultSuccessUrl("/home")
        .permitAll()
        .and()
        .logout()
        .invalidateHttpSession(true)
        .clearAuthentication(true)
        .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
        .logoutSuccessUrl("/login")
        .and()
        .exceptionHandling().authenticationEntryPoint(authenticationEntryPoint());  

    }
Run Code Online (Sandbox Code Playgroud)

当我运行应用程序(来自Spring Tool Suit)并通过 url 访问应用程序时

http://localhost:8080/myApp/login

它工作正常并打开登录页面

但是,当我进入

http://localhost:8080/myApp/

它将我重定向到 http://localhost:8080/login (这给出了一个 404 页面)

我想要 http://localhost:8080/myApp/ & http://localhost:8080/myApp/login 打开登录页面

登录页面位于项目文件夹的根目录中。另外,spring.mvc.view.suffix=.jsp我的 application.properties …

java spring-security contextpath spring-boot tomcat9

5
推荐指数
1
解决办法
589
查看次数