需要构建应用程序而不使用在Java3中使用的注释并且在开始时遇到一些问题。看起来像web.xml/view/controller中的设置是合乎逻辑的并应该起作用。给出一个404错误,如果我使用注释它不。我想这就是为什么赋值状态不使用注释!任何关于S.O的旧定时器的建议?Java Web应用程序不使用注释
P.S任何建议将真正帮助我开始这个应用程序,我在网上阅读,我已阅读的解决方案似乎并没有工作。而最终建议使用注释...我不能使用!
的welcome.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome Page</title>
</head>
<body>
<h1>Welcome Page</h1>
<br/>
<form action="/OptionsForYou" name="options">
<select>
<option>---Select---</option>
</select>
<button type="submit" value="submit">Submit</button>
</form>
</body>
</html>
OptionsWork.java
package com.server;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class OptionsWork
*/
public class OptionsWork extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
String options = req.getParameter("options");
System.out.println(options);
}
}
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>Options</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>OptionsWork</servlet-name>
<servlet-class>com.server.OptionsWork</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>OptionsWork</servlet-name>
<url-pattern>/OptionsForYou</url-pattern>
</servlet-mapping>
</web-app>
交叉检查您的依赖关系。 – Akshay
尝试在实现中指定load-on-startup和Sysout以确保servlet正在加载或未加载。也只是一个想法,您应该在