jsp 相关问题

JSP(JavaServer Pages)是一种在服务器上运行的基于Java的视图技术,它允许您在(客户端语言,如HTML,CSS,JavaScript等)中编写模板文本,并与后端Java代码进行交互。

Spring Tool Suite 4 未显示 JSP 文件选项

我正在学习一个教程,该教程希望我将 JSP 文件添加到练习中。当我尝试在向导中添加“其他”并搜索 JSP 时,它不是一个选项。 Spring Tool Suite 4 未显示选项...

回答 3 投票 0

为什么我无法从 tld 文件导入此函数?

我正在学习 Klausen JaveEE 书中的教程。 它是一个简单的 Web 应用程序,它将数字作为用户输入并检查它是否是素数。 我有一个 JSP 文件 (index.jsp) 和一个静态方法

回答 1 投票 0

用户“User”@“localhost”的 MySQL 访问被拒绝(使用密码:YES)

我在netbeans中为一个项目(java web应用程序)连接了MySQL数据库。我以 root 身份使用正确的登录详细信息创建了 MySQL 服务器并创建了一个数据库。我将数据库连接到项目...

回答 3 投票 0

JSP和JavaBeans,为什么我不能使用bean方法的返回值?

我正在学习JSP和javabean。我编写了一个简单的网络应用程序来计算贷款偿还额。应用程序使用用户输入(来自表单)正确设置 bean 的字段。该豆还含有

回答 1 投票 0

如何在.jsp文件中连接css和javascript

我在将外部 css 和 javascript 文件连接到其 jsp 时遇到问题。 我尝试在 google 上阅读时进行 WebConfig,但我意识到我的 jsp 文件路径是通过 application.proper 完成的...

回答 1 投票 0

<c:out/>未知标签

为什么当我包含以下行时,我在左侧的 Eclipse 中收到错误提示消息。 我收到错误“未知标签(c:out)” 我还包括在顶部 <%@ page isELIg...

回答 6 投票 0

使用JSP登录Facebook、gmail、twitter

我遵循了这个问题How to verify users with facebook Login in java,但很难遵循它。 Web 应用程序依赖于 Ejb 应用程序,因此我无法在

回答 2 投票 0

如何检索Struts 2中select标签的值

我正在使用 Struts 标签从我的数据库检索值,并以 JSP 页面上的表单显示我使用以下代码将值存储在列表对象中 ps = con.prepareStatement("...

回答 2 投票 0

如何在 Struts 2 jQuery <sj:select> 标签中访问嵌套的 JSON 响应

我正在使用 Struts2 及其 jQuery 插件开发一个 Web 应用程序。我的 标签如下所示,并且当我收到非嵌套 JSON 响应时工作得非常好: 我正在使用 Struts2 及其 jQuery 插件开发一个 Web 应用程序。我的 <sj:select> 标签如下所示,当我得到非嵌套 JSON 响应时,它工作得非常好: <s:url id="remoteurl" namespace="/XYZ" action="ZXY"/> <sj:select href="%{remoteurl}" id="abc" onChangeTopics="dosomething" name="cde" list="List" label="Customer" /> 从我的控制器中,我使用 AJAX 调用得到类似以下 JSON 响应的信息。 {"List1":null,"Object":{"List2":null,"Var1":null,"List3":{"8":"a","9":"b","10":"c","14":"d","15":"e"}} 在我的 <sj:select> 中,我想要 List3,这是一个 Object。但是使用上面显示的标签与 list=Object.List3 它不起作用。 它不起作用,因为首先使用列表属性中的值Object.List3来计算 OGNL 表达式,然后当失败时,它被用作 JSON 数组的名称(如果使用映射,则为 JSON 对象)。 但是标签<sj:select>使用该值作为根JSON对象,它不会导航到JSON对象的JSON数组,因为它没有使用JS中的任何对象图导航库。要使其正常工作,您需要在 JSON 结果中添加 root 参数 @Action(value="ZXY", results=@Result(type="json", params = {"root","Object"})) 然后使用 JSON 注释来指定 name(如果您想保留该名称) @JSON(name = "Object.List3") public Map<Integer,String> getList3() { return list3; } 那么 JSON 字符串将如下所示 {"List2":null,"Var1":null,"Object.List3":{"8":"a","9":"b","10":"c","14":"d","15":"e"}} 使用 Map<Integer,String> 而不是 List<Object>,因为它对应于您的 JSON 字符串,并且不是列表。

回答 1 投票 0

如何在 Struts 2 中将布尔 bean 属性与单选按钮绑定

我有一个后端 POJO(比如 MyBean),其中包含一个布尔属性 Boolean isValid。 我正在填充要在 JSP 上显示的 MyBean 列表。 现在我想在每个 MyBean 旁边有一个单选按钮,这样...

回答 1 投票 0

在 Struts 2 中提交时提交 JS 函数值

如何通过 JavaScript 函数在单击此 的 按钮时将 中隐藏字段内设置的值传递给操作类?

回答 1 投票 0

如何摆脱 Eclipse 中神秘的 JSP 问题

我在项目中的数十个 *.jsp 文件之一中存在以下错误: Eclipse 问题视图 文本编辑器中的第 0 行有点有趣,但是好吧,我们开发人员经常开始计算......

回答 1 投票 0

从操作类将数据发送到另一个 JSP 文件

主页有创建新记录的链接和显示所有现有记录的链接。 在 create_new_record 页面上,我正在将所有数据写入名为 saveRecords 的操作类方法中的文件...

回答 1 投票 0

注册操作返回请求的资源不可用

我有一个包含以下代码的表单: 请报名 <... 我有一个包含以下代码的表单: <form action="doRegister" class="form-signup" > <h2 class="form-signup-heading">Please sign up</h2> <input type="email" class="form-control" placeholder="Email address" required autofocus> <input type="password" class="form-control" placeholder="Password" required> <input type="password" class="form-control" placeholder="Password control" required> <input type="text" class="form-control" placeholder="Name" required> <input type="text" class="form-control" placeholder="Surname" required> <input type="date" class="form-control" placeholder="Born date" required> <button class="btn btn-lg btn-primary btn-block" type="submit">Sign up</button> </form 我有两个班级:UserRegisterForm和UserRegistrationAction UserRegisterForm: package com.github.jcpp.jathenaeum.action; import org.apache.struts.action.ActionForm; public class UserRegisterForm extends ActionForm{ private static final long serialVersionUID = 1; /*ATTRIBUTES of the form fields*/ /*METHODS Get and Set*/ public UserRegisterForm() { super(); } } UserRegistrationAction: package com.github.jcpp.jathenaeum.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.github.jcpp.jathenaeum.Utente; import com.github.jcpp.jathenaeum.db.dao.UtenteDAO; import com.github.jcpp.jathenaeum.exceptions.RegistrationException; public class UserRegistrationAction extends Action{ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //boolean action_perform = false; String action_target = null; Random rnd = new Random(); UtenteDAO userDao = new UtenteDAO(); Utente user = new Utente(); //ActionMessages errors_mesg = new ActionMessages(); UserRegisterForm uf = (UserRegisterForm) form; if(form != null){ user.setEmail(uf.getEmail()); user.setPassword(uf.getPassword()); user.setNome(uf.getName()); user.setCognome(uf.getSurname()); user.setDataNascita(uf.getBornDate()); user.setNumeroTessera(rnd.nextInt(999999)+1); try{ if(userDao.register(user)){ action_target = "success"; } }catch(Exception e){ action_target = "failed"; throw new RegistrationException(); } } return mapping.findForward(action_target); } 在我的struts-config.xml中我: <form-beans> <form-bean name="registerform" type="com.github.jcpp.jathenaeum.action.UserRegisterForm"/> </form-beans> <action-mappings> <action path="/index" type="org.apache.struts.actions.ForwardAction" parameter="page.index" /> <action path="/signin" type="org.apache.struts.actions.ForwardAction" parameter="page.signin" /> <action path="/signup" type="org.apache.struts.actions.ForwardAction" parameter="page.signup" /> <action path="/doRegister" type="com.github.jcpp.jathenaeum.action.UserRegistrationAction" name="registerform" scope="request" validate="true" input="signup"> <forward name="input" path="/index.jsp"/> <forward name="success" path="/welcome.jsp"/> <forward name="failure" path="/index.jsp"/> </action> </action-mappings> 我的错误报告是: 类型状态报告 留言 /JAthenaeum/doRegister 描述 请求的资源不可用。 为什么我会遇到这个问题? 问题在于表单中的 action 参数:在我的例子中它必须是 doRegister.do,而在 struts-config.xml 中,操作路径等于 /doRegister。所以,请看下面的代码: <form action="doRegister.do" > [...] </form> 并且在 struts-config.xml <action path="/doRegister" <!-- LOOK HERE --> type="com.github.jcpp.jathenaeum.action.UserRegistrationAction" name="registerform" scope="request" validate="true" input="/signup.jsp"> <!-- <forward name="input" path="/index.jsp"/> <forward name="success" path="/signin.jsp"/> <forward name="failed" path="/signup.jsp"/> --> </action> 该操作返回名为 "failed" 的未知转发。将其更改为配置为操作 "failure" 的值。应替换以下代码 try { if(!userDao.register(user)) { return mapping.findForward("failure"); } }catch(Exception e){ throw new RegistrationException(e); } return mapping.findForward("success"); 异常应该提供更多信息,告诉您异常的原因。 表格也应该映射到正确的操作 <html:form action="/doRegister" cssClass="form-signup" >

回答 2 投票 0

注册操作返回请求的资源不可用

我有一个包含以下代码的表单: 请报名 <... 我有一个包含以下代码的表单: <form action="doRegister" class="form-signup" > <h2 class="form-signup-heading">Please sign up</h2> <input type="email" class="form-control" placeholder="Email address" required autofocus> <input type="password" class="form-control" placeholder="Password" required> <input type="password" class="form-control" placeholder="Password control" required> <input type="text" class="form-control" placeholder="Name" required> <input type="text" class="form-control" placeholder="Surname" required> <input type="date" class="form-control" placeholder="Born date" required> <button class="btn btn-lg btn-primary btn-block" type="submit">Sign up</button> </form 我有两个班级:UserRegisterForm和UserRegistrationAction UserRegisterForm: package com.github.jcpp.jathenaeum.action; import org.apache.struts.action.ActionForm; public class UserRegisterForm extends ActionForm{ private static final long serialVersionUID = 1; /*ATTRIBUTES of the form fields*/ /*METHODS Get and Set*/ public UserRegisterForm() { super(); } } UserRegistrationAction: package com.github.jcpp.jathenaeum.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.github.jcpp.jathenaeum.Utente; import com.github.jcpp.jathenaeum.db.dao.UtenteDAO; import com.github.jcpp.jathenaeum.exceptions.RegistrationException; public class UserRegistrationAction extends Action{ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //boolean action_perform = false; String action_target = null; Random rnd = new Random(); UtenteDAO userDao = new UtenteDAO(); Utente user = new Utente(); //ActionMessages errors_mesg = new ActionMessages(); UserRegisterForm uf = (UserRegisterForm) form; if(form != null){ user.setEmail(uf.getEmail()); user.setPassword(uf.getPassword()); user.setNome(uf.getName()); user.setCognome(uf.getSurname()); user.setDataNascita(uf.getBornDate()); user.setNumeroTessera(rnd.nextInt(999999)+1); try{ if(userDao.register(user)){ action_target = "success"; } }catch(Exception e){ action_target = "failed"; throw new RegistrationException(); } } return mapping.findForward(action_target); } 在我的struts-config.xml中我: <form-beans> <form-bean name="registerform" type="com.github.jcpp.jathenaeum.action.UserRegisterForm"/> </form-beans> <action-mappings> <action path="/index" type="org.apache.struts.actions.ForwardAction" parameter="page.index" /> <action path="/signin" type="org.apache.struts.actions.ForwardAction" parameter="page.signin" /> <action path="/signup" type="org.apache.struts.actions.ForwardAction" parameter="page.signup" /> <action path="/doRegister" type="com.github.jcpp.jathenaeum.action.UserRegistrationAction" name="registerform" scope="request" validate="true" input="signup"> <forward name="input" path="/index.jsp"/> <forward name="success" path="/welcome.jsp"/> <forward name="failure" path="/index.jsp"/> </action> </action-mappings> 我的错误报告是: 类型状态报告 留言 /JAthenaeum/doRegister 描述 请求的资源不可用。 为什么我会遇到这个问题? 问题在于表单中的 action 参数:在我的例子中它必须是 doRegister.do,而在 struts-config.xml 中,操作路径等于 /doRegister。所以,请看下面的代码: <form action="doRegister.do" > [...] </form> 并且在 struts-config.xml <action path="/doRegister" <!-- LOOK HERE --> type="com.github.jcpp.jathenaeum.action.UserRegistrationAction" name="registerform" scope="request" validate="true" input="/signup.jsp"> <!-- <forward name="input" path="/index.jsp"/> <forward name="success" path="/signin.jsp"/> <forward name="failed" path="/signup.jsp"/> --> </action> 该操作返回名为 "failed" 的未知转发。将其更改为配置为操作 "failure" 的值。应替换以下代码 try { if(!userDao.register(user)) { return mapping.findForward("failure"); } }catch(Exception e){ throw new RegistrationException(e); } return mapping.findForward("success"); 异常应该提供更多信息,告诉您异常的原因。 表格也应该映射到正确的操作 <html:form action="/doRegister" cssClass="form-signup" >

回答 2 投票 0

提交表单到Servlet后如何在JSP中保留HTML表单字段值?

提交 HTML 中的数据后,servlet 将这些数据添加到我的数据库中,并将结果消息转发到 JSP 页面。我想在转发后保留表单中最初提交的值...

回答 2 投票 0

从JSP连接MySQL

我刚刚踏上JSP。我开始编写简单的程序来显示日期、系统信息。然后我尝试连接 MySQL 数据库我有一个免费的托管帐户,但我无法连接到 MySQL

回答 4 投票 0

如何将struts2中的字符集更改为utf-8

嗨,我有一个测试字段,我想在其中进行非英语测试(例如俄语) 但在我的动作课中,我得到的不仅仅是文本?????????。 我尝试编写简单的过滤器来描述

回答 4 投票 0

找不到文件

我的计划是检查所有文本字段是否为空。如果为空,我想显示错误消息并继续显示 SignUp.jsp。这是代码: if (uEmail.isEmpty() || uFName.is...

回答 1 投票 0

如何在按钮单击时在请求参数中传递 html 输入值

我有一个使用表内核心库动态生成的书籍列表。用户可以选择要添加到购物车的书籍数量,然后单击“添加到购物车”按钮。我想要的是...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.