2017-04-22 71 views

回答

1

你應該聲明和定義的類/ web.xml文件像這裏面的servlet:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee         http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> 
    <servlet> 
     <servlet-name>LoginForm</servlet-name> 
     <servlet-class>com.project.system.LoginForm</servlet-class> 
    </servlet> 
    <servlet> 
     <servlet-name>RegisterForm</servlet-name> 
     <servlet-class>com.project.system.RegisterForm</servlet-class> 
    </servlet> 
    <servlet> 
     <servlet-name>UserController</servlet-name> 
     <servlet-class>com.project.controller.UserController</servlet-class> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>LoginForm</servlet-name> 
     <url-pattern>/LoginForm</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>RegisterForm</servlet-name> 
     <url-pattern>/RegisterForm</url-pattern> 
    </servlet-mapping> 
    <servlet-mapping> 
     <servlet-name>UserController</servlet-name> 
     <url-pattern>/UserController</url-pattern> 
    </servlet-mapping> 
    <session-config> 
     <session-timeout> 
      30 
     </session-timeout> 
    </session-config> 
</web-app> 
+0

感謝,但我還是不明白。我怎樣才能指定哪個jsp應該由特定的servlet處理? – borderwing

+0

您可以處理Servlet文件中的JSP文件。有一些特定的方法,如request.getParameter(); –

+0

你也在你的JSP文件中聲明如下:

相關問題