@WebServlet配置initParams属性

@WebServlet(urlPatterns = { "/hello.view" }, loadOnStartup = 1, initParams = { @WebInitParam(name = "Site :", value = "http://roseindia.net"),
	@WebInitParam(name = "Rose", value = "India", description = "detail-info") })
public class ITSMServiceServlet extends HttpServlet {

	private static final long serialVersionUID = -5767625680763237936L;

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		String roseFrom = this.getInitParameter("Rose");
		PrintWriter out = resp.getWriter();
		// out.println("" + roseFrom + "");

	}

}
initParams = { @WebInitParam(name = "Site :", value = "http://roseindia.net"),@WebInitParam(name = "Rose", value = "India", description = "detail-info") }

你可能感兴趣的:(@WebServlet配置initParams属性)