我是本站新手,作爲程序員,我認爲自己是初學者/中級水平。我是java新手,必須使用JSP來完成大學課程。我想知道什麼是錯的這個代碼,因爲我收到此錯誤:JSP錯誤:請求的資源不可用
the requested resource is not available.
這裏是我的所有代碼:
session.jsp
<html>
<body>
<form method = Post action = 「receiveName.jsp」>
please enter your name: <input type = "text" name = "myname" size = 20></br>
<input type = "submit"><input type = "clear">
</form>
</body>
</html>
receiveName.jsp
<jsp:useBean id="bean" class="mynames.Names" scope="session"/>
<jsp:setProperty name="bean" property="myNames" param="myname"/>
<% String name = bean.getMyNames();
session.setAttribute(「user」, name);
%>
<html>
<body>
<a href = 「showname.jsp」>move to next page</a>
</body>
</html>
showName.jsp
<html>
<body>
Hello <% = session.getAttribute(「user」)%>
</body>
</html>
Names.java
package mynames;
public class Names{
private String myNames;
public Names(){
}
public void setMyNames(String name){
myNames = name;
}
public String getMyNames(){
return myNames;
}
}
我不明白如何實現bean的概念非常好,如果我單獨運行receiveName.jsp出現以下報告:
org.apache.jasper.JasperException: /EjemploProfesor/Class/receiveName.jsp (line: 1, column: 1) The value for the useBean class attribute mynames.Names is invalid.
您的每一個輸入都將非常感激。順便說一下,我沒有使用IDE,只是在Ubuntu中運行的Sublime Text 2以及服務器Apache Tomcat 8.0.21
有人能幫助我嗎?如果你看到另一種更簡單的方式來實現bean可以隨意分享它。我希望看到一個使用用戶名和密碼的例子。謝謝!! –