开发者

Java Spring address of page

开发者 https://www.devze.com 2023-03-27 03:48 出处:网络
I am really confused how does the address of my spring application come from. I followed the tutorial, but now I am trying to change the address, but I can\'t find the spot.

I am really confused how does the address of my spring application come from. I followed the tutorial, but now I am trying to change the address, but I can't find the spot.

At the moment address is this : http://localhost:8080/HelloWorld/

Where can I change HelloWorld to something else?

I will provide you with any code you need. I have two conf files : web.xml, spring-servlet.xml, but there is nothing in them that contains HelloWorld.

<?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"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-b开发者_如何学运维eans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="hello.spring3.controller" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass" 
            value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp" />
    </bean>

</beans>

and web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="spring3" version="3.0">

    <display-name>Spring display name</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <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>*.html</url-pattern>
    </servlet-mapping>


    </web-app>


Actually this is not issue unless you deploy it on production environament.

When you deploy it there you should create new HOST in TOMCAT_HOME/conf/server.xml file

it should look something like:

<Host name="www.mysite.com" appBase="www"   
      unpackWARs="true" autoDeploy="true"  
      xmlValidation="false" xmlNamespaceAware="false">  
</Host>  

Second option is to deploy your war file in ROOT directory, but in my opinion the first option is more suitable.

Update: No problem, If you are using eclipse, please click right mouse button on your project, Select Properties - > Web Project Settings. and change name of your "HelloWorld" directory.


It's the name of your war file.

0

精彩评论

暂无评论...
验证码 换一张
取 消