| |

VerySource

 Forgot password?
 Register
Search
View: 777|Reply: 4

A problem in Struts

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-8 18:00:01
| Show all posts |Read mode
12: <%
13: String name = (String) request.getAttribute ("keyname");
14: out.println (name);
15: String keyid = (String) request.getAttribute ("id");
16: out.println (keyid);
17: int id = Integer.parseInt (keyid);
18: out.println (keyid);






java.lang.ClassCastException: java.lang.Integer
org.apache.jsp.admin.SystemSetting.AddKeyWord_jsp._jspService (AddKeyWord_jsp.java:110)
org.apache.jasper.runtime.HttpJspBase.service (HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service (HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service (JspServlet.java:264)
javax.servlet.http.HttpServlet.service (HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward (RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.processForwardConfig (RequestProcessor.java:388)
org.apache.struts.action.RequestProcessor.process (RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process (ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet (ActionServlet.java:397)
javax.servlet.http.HttpServlet.service (HttpServlet.java:689)
javax.servlet.http.HttpServlet.service (HttpServlet.java:802)




How to solve it? ?
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-6-1 09:00:01
| Show all posts
It seems that LZ should be wrong with this sentence:
       String keyid = (String) request.getAttribute ("id");

  When you look at request.setAttribute (), whether it is a String type or an Integer.
Reply

Use magic Report

0

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-6-1 17:45:01
| Show all posts
Wrong code, wrong type
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-29 20:45:01
| Show all posts
17: int id = Integer.parseInt(keyid);


-------------------
Change to:
  int id = Integer.parseInt(keyid.trim());
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-7-20 09:00:01
| Show all posts
Thank you, I have solved it, and it is almost the same aswwwzfslcomsaid
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list