Servlet 3.0:访问localhost:8080的空白页面

时间:2016-09-01 09:49:48

标签: java ant servlet-3.0

我将首先启动servlet。我得到一个空页面。 请有人帮助我。

的Servlet

@WebServlet("")
public class PageNavigation extends HttpServlet {

    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {


        PrintWriter out = response.getWriter();
        out.print("hello");

    }
}

的web.xml

    <servlet>
            <servlet-name>PagesNavigation</servlet-name>
            <servlet-class>com.via.products.PagesNavigation</servlet-class>
        </servlet>


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

的build.xml

<?xml version="1.0" encoding="UTF-8" ?>
<project name="Fun" basedir="/Users/anjanaa/Documents/workspace/Fun" default="build">
<property name="src" location="src/java" />
<property name="jsp" location="src/jsp" />
<property name="image" location="src/image" />
<property name="css" location="src/css" />
<property name="webapp" location="webapp/ROOT/WEB-INF" />
<property name="ext-jar" location="lib" />
<property name="dest" location="${webapp}/classes" />
<property name="jspDir" location="webapp/ROOT/jsp" />
<property name="imageDir" location="webapp/ROOT/image" />
<property name="cssDir" location="webapp/ROOT/css" />
<property name="jar" location="${webapp}/lib/" />

<path id="build.classpath">
    <fileset dir="${ext-jar}">
        <include name="*.jar" />
        <include name="**/*.properties" />
    </fileset>
</path>

<target name="clean">

</target>

<target name="compile" depends="clean">
    <mkdir dir="${webapp}" />
    <mkdir dir="${webapp}/classes" />
    <mkdir dir="webapp/ROOT/jsp" />
    <mkdir dir="webapp/ROOT/image" />
    <mkdir dir="webapp/ROOT/css" />
    <mkdir dir="${webapp}/lib" />
    <mkdir dir="${webapp}/jarDir" />
    <javac srcdir="${src}" destdir="${dest}" includeantruntime="false" classpathref="build.classpath" debug="true" />
    <javac srcdir="${jsp}" destdir="${jspDir}" includeantruntime="false" classpathref="build.classpath" debug="true" />
    <javac srcdir="${image}" destdir="${imageDir}" includeantruntime="false" classpathref="build.classpath" debug="true" />
    <javac srcdir="${css}" destdir="${cssDir}" includeantruntime="false" classpathref="build.classpath" debug="true" />


</target>

<target name="jar" depends="compile">
    <jar destfile="webapp/ROOT/WEB-INF/jarDir/shopping.jar" basedir="${dest}">

    </jar>
</target>

<target name="copyjar" depends="jar">
    <copy todir="${webapp}/lib">
        <fileset dir="webapp/ROOT/WEB-INF/jarDir" includes="**/*.jar" />
        <fileset dir="lib" includes="**/*.jar" excludes="j*.jar" />
    </copy>

    <copy todir="${webapp}/classes">
        <fileset dir="${src}/utility" includes="*.properties" />
    </copy>

    <copy todir="webapp/ROOT/jsp">
        <fileset dir="${jsp}" includes="*.jsp" />
    </copy>

    <copy todir="webapp/ROOT/image">
        <fileset dir="${image}" />
    </copy>

    <copy todir="webapp/ROOT/css">
        <fileset dir="${css}" includes="*.css" />
    </copy>

</target>

<target name="build" depends="copyjar">
    <java jar="webapp/ROOT/WEB-INF/jarDir/shopping.jar" fork="true">
        <classpath path="build.classpath" />
    </java>
</target>
</project>

Project Structure

当我给localhost:8080时,我得到一个空白页面。我应该得到输出,但我没有得到任何。我的build.xml文件有问题吗?

My Output

感谢您的帮助..

0 个答案:

没有答案