我被限制在使用 Netbeans IDE 的企业软件项目上工作,没有框架。
前端显示是register.jsp
。我的模型包包含Customer.java
类,带有一些 getter 和 setter。数据包包含“CustomerData.java”,具有与客户相关的 DB 功能:注册、登录 CustomerData
等HttpServlet
。
CustomerData
我需要从我的注册表单中引用类中的特定方法。这可能吗?
如果可以这样做,web.xml
文件条目应该是servlet
什么servletmapping
?
这是代码。
注册.jsp
<form name="loginForm" method="post" action="CustomerData/RegisterCustomer">
......
</form>
CustomerData.java骨架:
public class CustomerData extends HttpServlet {
public void registerCustomer(HttpServletRequest request)
throws ServletException, IOException
{
// this is the method I need to reference. It creates a db connection, checks to see if
// the Customer is already in the DB, and if not, registers the user.
}
public void loginCustomer(HTTPServlet request)
throws ServletException, IOException
{
// Some other Customer data method that will need to be called from my login.jsp page
}
public void SomeOtherMethod()
{
// some helper methods or validation methods for Customer
}
}