मैं स्प्रिंग एमवीसी वेब एप्लिकेशन पर कुछ अन्य लोगों के साथ काम कर रहा हूं। यदि मैं एप्लिकेशन का उपयोग करता हूं तो वह URL का उपयोग करता है http://localhost:8080/mywebapp लेकिन यदि अन्य इसे चलाते हैं, तो एप्लिकेशन URL का उपयोग करता है http://localhost:8080/x.
क्या कोई कॉन्फ़िगरेशन है जो मैं एप्लिकेशन को किसी विशिष्ट URL पर चलने दे सकता हूं?
applicationContext.xml
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="z.y.x.mywebapp" />
<mvc:annotation-driven />
<import resource="hibernate-context.xml" />
</beans>
web.xml
<?xml version="1.0" encoding="utf-8"?>
<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">
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.png</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
spring-servlet.xml
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
मैं इसके लिए काफी नया हूं, अगर कोई सूचना गायब है तो कृपया मुझे बताएं।
धन्यवाद
उत्तर:
जवाब के लिए 2 № 1tomcat के भीतर server.xml में इसकी परिभाषा:
<Context docBase="yourSource" path="/yourPath" ...
यदि युद्ध फ़ाइलों का उपयोग किया जाता है, तो युद्ध फ़ाइल का नाम ही (आप केवल एक नाम बदलकर राइट क्लिक कर सकते हैं), जो कि अगर मावेन का उपयोग करते हुए pom में सेट किया गया है:
<build><finalname>blahblah