我的要求是尝试从项目表填充pid(projectid),从userdetails表填充名称作为表单的下拉列表。作为struts框架的新手。有人可以请你解决这个问题。
以下是代码:
sprintform.jsp :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<?xml version="1.0" encoding="UTF-8" ?>
<!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>Insert title here</title>
<link href="css/jquery.ui.datepicker.css" rel="stylesheet"
type="text/css" />
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.17.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){$('.dateTxt').datepicker({
dateFormat : 'yy-mm-dd'
}); });
</script>
</head>
<body>
<h1 style="color: green">Sprint</h1>
<s:form action="sprintInsert" namespace="/" method="post"
name="sprintForm" theme="xhtml">
<s:textfield name="title:" size="40" maxlength="40" required="true"
label="Title" />
<p>
Begin Date: <input id="one" class="dateTxt" type="text"
name="begindate" />
</p>
<p>
End Date: <input id="two" class="dateTxt" type="text" name="enddate" />
</p>
<s:select label="ProjectId" headerKey="-1"
headerValue="Select Project Id" list="projectidList" name="pid" />
<%-- <s:select label="Owner" headerKey="-1"
headerValue="Select Sprint Owner" list="sprintownerList"
name="sprintowner" /> --%>
<tr>
<td>State:</td>
<td><select name="state">
<option value="">Choose a state..</option>
<option value="A">Active</option>
<option value="F">Future</option>
<option value="C">Close</option>
</select></td>
</tr>
<s:textfield name="targetestimatedpoints" size="40" maxlength="40"
required="true" label="Target Estimate pts:" />
<s:textfield name="totalestimatedpoints" size="40" maxlength="40"
required="true" label="Total Estimate pts:" />
<s:textfield name="totaldefaultestimatedhours" size="40"
maxlength="40" required="true" label="Total Detail Estimate Hrs: " />
<s:textfield name="todohours:" size="40" maxlength="40"
required="true" label="Total To Do Hrs:" />
<s:textfield name="description: :" size="40" maxlength="40"
required="true" label="Description: " />
<tr align="right">
<td><div align="center">
<input type="submit" value="save">
</div>
<td align="center"><input type="reset" value="Reset"></td>
</tr>
</s:form>
<s:if test="hasActionErrors()">
<div id="fieldErrors">
<s:actionerror />
</div>
</s:if>
</body>
</html>
SprintAction.java :
package com.bits.sprintanalyzer.action;
import java.util.List;
import org.apache.log4j.Logger;
import com.bits.sprintanalyzer.ResourceException;
import com.bits.sprintanalyzer.dao.SprintDAO;
import com.opensymphony.xwork2.ActionSupport;
public class SprintAction extends ActionSupport {
private static final Logger LOG = Logger.getLogger(SprintAction.class);
/**
*
*/
private static final long serialVersionUID = -6257623073537028210L;
private String title;
private String begindate;
private String enddate;
private String pid;
private String sprintowner;
private String state;
private int targetestimatedpoints;
private int totalestimatedpoints;
private int totaldefaultestimatedhours;
private int todohours;
private String description;
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getSprintowner() {
return sprintowner;
}
public void setSprintowner(String sprintowner) {
this.sprintowner = sprintowner;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public int getTargetestimatedpoints() {
return targetestimatedpoints;
}
public void setTargetestimatedpoints(int targetestimatedpoints) {
this.targetestimatedpoints = targetestimatedpoints;
}
public int getTotalestimatedpoints() {
return totalestimatedpoints;
}
public void setTotalestimatedpoints(int totalestimatedpoints) {
this.totalestimatedpoints = totalestimatedpoints;
}
public int getTotaldefaultestimatedhours() {
return totaldefaultestimatedhours;
}
public void setTotaldefaultestimatedhours(int totaldefaultestimatedhours) {
this.totaldefaultestimatedhours = totaldefaultestimatedhours;
}
public int getTodohours() {
return todohours;
}
public void setTodohours(int todohours) {
this.todohours = todohours;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String display() throws Exception {
return INPUT;
}
public String getBegindate() {
return begindate;
}
public void setBegindate(String begindate) {
this.begindate = begindate;
}
public String getEnddate() {
return enddate;
}
public void setEnddate(String enddate) {
this.enddate = enddate;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<String> getpidList() throws ResourceException {
return SprintDAO.getpidList();
}
public List<String> getOwnerList() throws ResourceException {
return SprintDAO.getOwnerList();
}
@Override
public void validate() {
}
@Override
public String execute() throws Exception {
LOG.info("title" + title);
LOG.info("begindate" + begindate);
LOG.info("enddate" + enddate);
LOG.info("pid" + pid);
LOG.info("sprintowner" + sprintowner);
LOG.info("state" + state);
LOG.info("targetestimatedpoints" + targetestimatedpoints);
LOG.info("totalestimatedpoints" + totalestimatedpoints);
LOG.info("totaldefaultestimatedhours" + totaldefaultestimatedhours);
LOG.info("todohours" + todohours);
LOG.info("description" + description);
// ProjectDAO.insert(projectname,description,scrummaster,productowner,begindate,enddate);
int i = SprintDAO.save(this);
if (i > 0) {
return "success";
}
return "error";
}
}
SprintDAO :
package com.bits.sprintanalyzer.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.bits.sprintanalyzer.ResourceException;
import com.bits.sprintanalyzer.action.SprintAction;
import com.bits.sprintanalyzer.util.ConnectionUtil;
public class SprintDAO {
private static final String PROJECTQUERY = "select pid from project";
private static final String USERQUERY = "select name from userdetail";
public static List<String> getpidList() throws ResourceException{
List<String> projectidList = new ArrayList<String>();
// this should be populated from DB
try (Connection con = ConnectionUtil.INSTANCE.getConnection();
PreparedStatement st = con.prepareStatement(PROJECTQUERY)){
ResultSet rs =st.executeQuery();
while(rs.next()){
projectidList.add(rs.getString(1));
}
return projectidList;
}
catch (SQLException | ResourceException e) {
throw new ResourceException("Failed to validate project id", e);
}
}
public static List<String> getOwnerList() throws ResourceException{
List<String> sprintownerList = new ArrayList<String>();
// this should be populated from DB
try (Connection con = ConnectionUtil.INSTANCE.getConnection();
PreparedStatement st = con.prepareStatement(USERQUERY)){
ResultSet rs =st.executeQuery();
while(rs.next()){
sprintownerList.add(rs.getString(1));
}
return sprintownerList;
}
catch (SQLException | ResourceException e) {
throw new ResourceException("Failed to validate productowner", e);
}
}
//insert into database
public static int save(SprintAction SA) throws Exception{
int status=0;
try{
Connection con = ConnectionUtil.INSTANCE.getConnection();
PreparedStatement ps = con.prepareStatement("insert into sprint(pid,title,begindate,enddate,owner,state,targetestimatedpoints,totalestimatedpoints,totaldefaultestimatedhours,todohours,description) values(?,?,?,?,?,?,?,?,?,?,?)");
ps.setString(1, SA.getPid());
ps.setString(2, SA.getTitle());
ps.setString(3, SA.getBegindate());
ps.setString(4, SA.getEnddate());
ps.setString(5, SA.getSprintowner());
ps.setString(6, SA.getState());
ps.setInt(7, SA.getTargetestimatedpoints());
ps.setInt(8, SA.getTotalestimatedpoints());
ps.setInt(9, SA.getTotaldefaultestimatedhours());
ps.setInt(10, SA.getTodohours());
ps.setString(11, SA.getDescription());
status=ps.executeUpdate();
}catch(Exception e){
e.printStackTrace();}
return status;
}
}
struts.xml中:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"/WEB-INF/classes/struts-2.1.7.dtd">
<struts>
<!--
You could also set the constants in the struts.properties file
placed in the same directory as struts.xml
-->
<constant name="struts.devMode" value="true" />
<package name="sprintanalyzer" extends="struts-default" namespace="/">
<!--
If no class attribute is specified the framework will assume success and
render the result index.jsp
If no name value for the result node is specified the success value is the default
-->
<action name="">
<result>/jsp/login.jsp</result>
</action>
<!--
If the URL is hello.action then call the execute method of class HelloWorldAction.
If the result returned by the execute method is success render the HelloWorld.jsp
-->
<action name="login" class="com.bits.sprintanalyzer.action.LoginAction"
method="execute">
<result name="success">/jsp/sprintanalyzer.jsp</result>
<result name="input">/jsp/login.jsp</result>
</action>
<action name="projectform" class="com.bits.sprintanalyzer.action.ProjectAction"
method="display">
<result name="input">/jsp/projectform.jsp</result>
</action>
<action name="projectInsert" class="com.bits.sprintanalyzer.action.ProjectAction"
method="execute">
<result name="success">/jsp/sprintanalyzer.jsp</result>
</action>
<action name="sprintform" class="com.bits.sprintanalyzer.action.SprintAction"
method="display">
<result name="input">/jsp/sprintform.jsp</result>
</action>
<action name="sprintInsert" class="com.bits.sprintanalyzer.action.SprintAction"
method="execute">
<result name="success">/jsp/sprintanalyzer.jsp</result>
</action>
</package>
</struts>
问题来自projectidlist
和sprintownerList
。请相应地告知。
请在下面找到stacktrace:
2016-10-01T18:23:38.916+0530|Info: 2016-10-01 18:23:38,916 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The first TextProvider in the ValueStack (com.opensymphony.xwork2.ActionSupport) could not locate the message resource with key 'Login'
2016-10-01T18:23:38.917+0530|Info: 2016-10-01 18:23:38,917 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The default value expression 'Login' was evaluated and did not match a property. The literal value 'Login' will be used.
2016-10-01T18:23:38.925+0530|Info: 2016-10-01 18:23:38,924 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The first TextProvider in the ValueStack (com.opensymphony.xwork2.ActionSupport) could not locate the message resource with key 'Login'
2016-10-01T18:23:38.925+0530|Info: 2016-10-01 18:23:38,925 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The default value expression 'Login' was evaluated and did not match a property. The literal value 'Login' will be used.
2016-10-01T18:23:57.121+0530|Info: 2016-10-01 18:23:57,120 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The first TextProvider in the ValueStack (com.opensymphony.xwork2.ActionSupport) could not locate the message resource with key 'Login'
2016-10-01T18:23:57.121+0530|Info: 2016-10-01 18:23:57,121 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The default value expression 'Login' was evaluated and did not match a property. The literal value 'Login' will be used.
2016-10-01T18:23:57.128+0530|Info: 2016-10-01 18:23:57,128 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The first TextProvider in the ValueStack (com.opensymphony.xwork2.ActionSupport) could not locate the message resource with key 'Login'
2016-10-01T18:23:57.129+0530|Info: 2016-10-01 18:23:57,128 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The default value expression 'Login' was evaluated and did not match a property. The literal value 'Login' will be used.
2016-10-01T18:24:03.841+0530|Severe: Sat Oct 01 18:24:03 IST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2016-10-01T18:24:04.022+0530|Info: 2016-10-01 18:24:04,021 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The first TextProvider in the ValueStack (com.bits.sprintanalyzer.action.LoginAction) could not locate the message resource with key 'welcome to Sprint Analyzer Tool'
2016-10-01T18:24:04.022+0530|Info: 2016-10-01 18:24:04,022 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The default value expression 'welcome to Sprint Analyzer Tool' was evaluated and did not match a property. The literal value 'welcome to Sprint Analyzer Tool' will be used.
2016-10-01T18:24:06.835+0530|Warning: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'pid': The requested list key 'projectidList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:237)
at org.apache.struts2.components.Component.findValue(Component.java:358)
at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:856)
at org.apache.struts2.components.UIBean.end(UIBean.java:510)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
at org.apache.jsp.jsp.sprintform_jsp._jspx_meth_s_select_0(sprintform_jsp.java:236)
at org.apache.jsp.jsp.sprintform_jsp._jspx_meth_s_form_0(sprintform_jsp.java:144)
at org.apache.jsp.jsp.sprintform_jsp._jspService(sprintform_jsp.java:88)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:875)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:739)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:575)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:546)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:428)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:378)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:154)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptorcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
2016-10-01T18:24:06.844+0530|Warning: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'pid': The requested list key 'projectidList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:237)
at org.apache.struts2.components.Component.findValue(Component.java:358)
at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:739)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:575)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:546)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:428)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:378)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:154)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
at
以下是登录代码:
package com.bits.sprintanalyzer.action;
import org.apache.log4j.Logger;
import com.bits.sprintanalyzer.ResourceException;
import com.bits.sprintanalyzer.dao.LoginDAO;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
private static final Logger LOG = Logger.getLogger(LoginAction.class);
/**
*
*/
private static final long serialVersionUID = 6877145894906143530L;
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public void validate(){
if (username==null || username.length()==0 || password ==null || password.length() ==0 )
addActionError(getText("User name or Password cannot be null"));
}
@Override
public String execute() throws Exception {
try{
if( LoginDAO.isValidUser(username, password) ){
return SUCCESS;
}
else
{
addActionError(getText("Invalid Username or Password"));
}
}catch(ResourceException e){
LOG.error("Failed to valid User", e);
addActionError(getText("Something Went wrong with DBConnection"));
}
return INPUT;
}
}
更改连接字符串后的最新堆栈跟踪:
2016-10-01T18:55:04.396+0530|Warning: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'pid': The requested list key 'projectidList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:237)
at org.apache.struts2.components.Component.findValue(Component.java:358)
at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:856)
at org.apache.struts2.components.UIBean.end(UIBean.java:510)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
at va:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
答案 0 :(得分:0)
1)您有MySQL连接异常,如下所示:
Establishing SSL connection without server's identity verification is not recommended.
According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set.
要解决此问题,请使用如下连接字符串:(将数据库名称更改为现有数据库名称)
jdbc:mysql://localhost:3306/dbname?autoReconnect=true&useSSL=false
这需要先排序,这就是为什么没有渲染变量的值
2)在最新跟踪中,请求的列表键“ projectidList ”无法解析为集合/数组/映射/枚举/迭代器类型。
当您尝试访问尚未创建的列表/集合时,会发生此错误。
尝试在类级别初始化集合对象List<String> projectidList
。
当此时触发特定操作时,JSP页面不知道字段的类型,在这种情况下,当您编写List<String> projectidList = new ArrayList<String>();
而不是此时,请将其更改为ArrayList projectidList = new ArrayList();
。
确保在实例化操作类之后访问列表,即调用相应的操作。 如果你想在调用action之前直接访问它,请将其设置为静态并在jsp中访问它。