2017-01-25 29 views
0

單擊按鈕添加組織時,表單將顯示參數IDNAME。在用戶點擊提交按鈕後輸入IDNAME後,給定的條目應該被存儲,並且當在主頁中查看組織的主表時,它應該具有由用戶輸入的值。你可以使用任何東西MVCJSPJAVA或任何東西。如何將動態輸入的值以jsp格式保存到arraylist中?

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<!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=ISO-8859-1"> 
<title> Organization List</title> 
</head> 

<body> 

<table border= '1' class="floatedTable"> 
<thead> 
    <tr> 
     <th>Organization ID</th> 
     <th>Organization Name</th> 
    </tr> 
</thead> 

<tr> 
     <td>1</td> 
     <td>Tieto</td> 
</tr> 
<tr> 
     <td>2</td> 
     <td>Microsoft</td> 
</tr> 
<tr> 
     <td>3</td> 
     <td>Google</td> 
</tr> 
<tr> 
     <td>4</td> 
     <td>Chevron</td> 
</tr> 
</table> 

<br> 
<table border= '1' class="floatedTable"> 
<thead> 
    <tr> 
     <th>Employee ID</th> 
     <th>Employee Name</th> 
     <th>Employee Address</th> 
     <th>Employee Works in</th> 
    </tr> 
</thead> 

<tr> 
     <td>1</td> 
     <td>Dheeraj Kumar</td> 
     <td>Pune</td> 
     <td>Tieto</td>  
</tr> 
<tr> 
     <td>2</td> 
     <td>Revan</td> 
     <td>Wagholi</td> 
     <td>Microsoft</td> 
</tr> 
<tr> 
     <td>3</td> 
     <td>Deepali</td> 
     <td>karvenagar</td> 
     <td>Google</td> 
</tr> 
<tr> 
     <td>4</td> 
     <td>Amol</td> 
     <td>Bavdan</td> 
     <td>Chevron</td> 

</tr> 
</table> 
<br> 
<button type="button" onclick="location = 'AddOrganisation.jsp'">ADD Organization</button> 

<button type="button" onclick="location = 'AddEmployee.jsp'">ADD Employee</button> 
</body> 
</html> 
+0

我沒有看到問題,只有一個要求。你有什麼嘗試,這裏有一個靜態表,你將在哪裏存儲值(數據庫,文件,緩存,cookie,會話...)。然後,JSP或JSTL在哪裏生成具有這些值的表。你只有一個HTML模板,但沒有什麼功能,這是一個短暫的尋求幫助,你應該搜索教程(我建議你一個很好的JSP/JSTL教程) – AxelH

回答

-2

您可以使用一個典型Spring MVC

春控制器的方法:

@RequestMapping(value = "/organizations", method = RequestMethod.POST) 
    public String save(@ModelAttribute("organizationForm") @Validated User user, 
      BindingResult result, Model model, 
      final RedirectAttributes redirectAttributes) 

Spring Form in jsp :  
<form:form method="post" modelAttribute="organizationForm" action="/organizations"> 
<form:input path="name" type="text" /> 

使用模型屬性映射您的輸入從JSP動態形成控制器和結果存儲在同一個對象,它可以在主頁中查看。

你需要Spring庫像

org.springframework.asm-xyzjar

org.springframework.beans-xyzjar

org.springframework.context-xyzjar

org.springframework.core-xyzjar

org.springframework.expression-x .yzjar

org.springframework.web.servlet-xyzjar

org.springframework.web-xyzjar

彈簧web.jar

參考任何Spring MVC與模型屬性實現將爲您的目的服務。

相關問題