title: Type Mismatch cannot convert from type Optional<User> to User
body: <p>I am trying to create a website that allows the user to update, edit, delete, etc., and I have got to the part of Updating or Editing user’s information. I have tried multiple times using different ways, but I cannot seem to get past the error. I am completely oblivious to Optional&lt;> I just don’t get it. I have read <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html" rel="noreferrer">https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html</a>, but i dont understand how it should be coded, its just not clicking. If someone could please inform on how it should be coded in my code and please explain it I would be so grateful. Maybe its because im overworked and have not slept, but i cannot seem to correct this error. This is the error i get on the page when i attempt to edit the information for a user: </p>
  
  <p>There was an unexpected error (type=Internal Server Error, status=500).
  For input string: "id"
  java.lang.NumberFormatException: For input string: id</p>
  
  <pre><code>    //Repository
  
      public interface UserRepository extends CrudRepository&lt;User, Integer&gt; {
       }
  </code></pre>
  
  <p>here is the UserService</p>
  
  <pre><code>    //UserService
  
      @Service
      @Transactional
      public class UserService {
  
          private final UserRepository userRepository;
  
          public UserService(UserRepository userRepository) {
              this.userRepository=userRepository;
  
          }
          public void saveMyUser(User user) {
              userRepository.save(user);
          }
  
          public List&lt;User&gt; showAllUsers(){
  
              List&lt;User&gt; users = new ArrayList&lt;User&gt;();
              for(User user: userRepository.findAll()) {
                  users.add(user);
              }
  
              return users;
          }
  
          public void deleteMyUser(int id) {
              userRepository.deleteById(id);
  
          }
  
          public User editUser (int id) {
  
              return userRepository.findById(id);//I also get an error here as well
          }
  
      }
  </code></pre>
  
  <p>here is the controller</p>
  
  <pre><code>    //Application Controller
  
      @Controller
      public class ApplicationController {
  
          @Autowired
          private UserService userService;
  
          // THIS IS WHERE I GET THE ERROR
  
          @RequestMapping("/edit-user")
          public String editUser(@RequestParam int id,HttpServletRequest request) {
  
              /* OPTIONAL&lt;?&gt; is this where i would implement the 
                 optional what do i have to put here exactly? 
                 I tried some ways I read about but its not working for me */
  
              request.setAttribute("user", userService.editUser(id));
              request.setAttribute("mode", "MODE_UPDATE");
              return "welcome";
          }
  
      }
  </code></pre>
  
  <p>Thank you for the help in advance Im a little frustrated with this because I have been trying to correct this error all night.</p>