說明:A: 如今Artifacts已有了發佈的項目了(idea中準確的說應是Modele) B:output root目錄描述了當前項目的編譯目錄及適配服務。html
肯定以後當前項目的結構:java
注:不少童鞋在這裏找不到Arifact,請參考部署項目中的Modules的配置。若是沒有爲項目配置Web服務組件,那麼就沒有Artifact。(當前項目連Web項目都不是,哪兒來的Artifact,又部署什麼呢?)web
添加完畢瀏覽器
Java服務器
package com.wql; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; /** * Created by Lenovo on 2016/2/25. */ @WebServlet("/myController") public class Controller extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doPost(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // System.err.println("---"); //解決亂碼 req.setCharacterEncoding("UTF-8"); String name=req.getParameter("name"); req.setAttribute("name",name); System.out.println(name); req.getRequestDispatcher("index.jsp").forward(req, resp); } }
Htmlapp
<%-- Created by IntelliJ IDEA. User: Lenovo Date: 2016/2/25 Time: 0:26 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <form action="myController" method="post"> <input name="name"> return:${name} <input value="提交" type="submit"> </form> </body> </html>
Xmlwebapp
<?xml version="1.0" encoding="UTF-8"?> <web-app 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" version="3.0"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>